summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorapense <apense@users.noreply.github.com>2015-06-24 03:33:48 -0400
committerapense <apense@users.noreply.github.com>2015-06-24 03:33:48 -0400
commit67b3c4b31f10845d0713c3891c77f07f70ffe04c (patch)
tree889ad4ddc0d5b77dfffc587f6202aa2b6104a00d /lib
parent5f371e1504a7a0cc18262b4b7e2ad55de3ab8325 (diff)
downloadNim-67b3c4b31f10845d0713c3891c77f07f70ffe04c.tar.gz
Added documentation for mod
Along with a brief example for sign demonstration
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/math.nim6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/pure/math.nim b/lib/pure/math.nim
index 494dfc4c8..7a88694b5 100644
--- a/lib/pure/math.nim
+++ b/lib/pure/math.nim
@@ -318,6 +318,12 @@ else:
 {.pop.}
 
 proc `mod`*(x, y: float): float =
+  ## Computes the modulo operation for float operators. Equivalent
+  ## to ``x - y * floor(x/y)``. Note that the remainder will always
+  ## have the same sign as the divisor.
+  ## 
+  ## .. code-block:: nim
+  ##  echo (4.0 mod -3.1) # -2.2
   result = if y == 0.0: x else: x - y * (x/y).floor
 
 proc random*[T](x: Slice[T]): T =