summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorapense <apense@users.noreply.github.com>2015-06-24 14:49:15 -0400
committerapense <apense@users.noreply.github.com>2015-06-24 14:49:15 -0400
commitbfcbe64778f5bd9580aac9a2ae8c735257a2bade (patch)
tree2294100a244889bd813cb48683d6f471962461ca
parentedbd191f74996e6469cf5d45171046c38851e208 (diff)
downloadNim-bfcbe64778f5bd9580aac9a2ae8c735257a2bade.tar.gz
Specific float32/float64 procs
I still used generics, but made them choose from `float32` or `float64`. I can rewrite in separate, explicit procs if is wanted
-rw-r--r--lib/pure/math.nim12
1 files changed, 4 insertions, 8 deletions
diff --git a/lib/pure/math.nim b/lib/pure/math.nim
index 2dc66bc25..f83ca6064 100644
--- a/lib/pure/math.nim
+++ b/lib/pure/math.nim
@@ -16,10 +16,6 @@
 ## Note that the trigonometric functions naturally operate on radians.
 ## The helper functions `degToRad` and `radToDeg` provide conversion
 ## between radians and degrees.
-## 
-## Note that the trigonometric functions naturally operate on radians.
-## The helper functions `degToRad` and `radToDeg` provide conversion
-## between radians and degrees.
 
 include "system/inclrtl"
 {.push debugger:off .} # the user does not want to trace a part
@@ -326,13 +322,13 @@ else:
 
 {.pop.}
 
-proc degToRad*[T](d: T): float {.inline.} =
+proc degToRad*[T: float32|float64](d: T): T {.inline.} =
   ## Convert from degrees to radians
-  result = float(d) * RadPerDeg
+  result = T(d) * RadPerDeg
 
-proc radToDeg*[T](d: T): float {.inline.} =
+proc radToDeg*[T: float32|float64](d: T): T {.inline.} =
   ## Convert from radians to degrees
-  result = float(d) / RadPerDeg
+  result = T(d) / RadPerDeg
 
 proc `mod`*(x, y: float): float =
   result = if y == 0.0: x else: x - y * (x/y).floor