Nyquist / XLISP 2.0  -  Contents | Tutorials | Examples | Reference

Remainder and Modulus


The cl:mod and cl:rem function are generalizations of the modulus and remainder functions.

The cl:mod and cl:rem functions are the modulus and remainder functions when the 'number' and 'divisor' arguments both are integers.

(mod  13    4)  =>  1          (rem  13    4)  =>  1 
(mod -13    4)  =>  3          (rem -13    4)  => -1 
(mod  13   -4)  => -3          (rem  13   -4)  =>  1 
(mod -13   -4)  => -1          (rem -13   -4)  => -1 
(mod  13.4  1)  =>  0.4        (rem  13.4  1)  =>  0.4 
(mod -13.4  1)  =>  0.6        (rem -13.4  1)  => -0.4

  Back to top


Nyquist / XLISP 2.0  -  Contents | Tutorials | Examples | Reference