mod ( x y -- z )
Factor handbook » The language » Numbers » Arithmetic » Modular arithmetic

Next:rem ( x y -- z )


Vocabulary
math

Inputs
xa rational
ya rational


Outputs
za rational


Word description
Computes the remainder of dividing x by y, with the remainder being negative if x is negative.
Modulus of fixnums always yields a fixnum.
Modulus of bignums always yields a bignum.
Modulus of rationals always yields a rational. In this case, the remainder is computed using the formula x - (x mod y) * y.


See also
Division by zero, rem

Definition


Methods