Added documentation for mod
Along with a brief example for sign demonstration
This commit is contained in:
parent
5f371e1504
commit
67b3c4b31f
1 changed files with 6 additions and 0 deletions
|
|
@ -318,6 +318,12 @@ else:
|
||||||
{.pop.}
|
{.pop.}
|
||||||
|
|
||||||
proc `mod`*(x, y: float): float =
|
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
|
result = if y == 0.0: x else: x - y * (x/y).floor
|
||||||
|
|
||||||
proc random*[T](x: Slice[T]): T =
|
proc random*[T](x: Slice[T]): T =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue