Nyquist / XLISP 2.0 -
Contents |
Tutorials |
Examples |
Reference
cl:mod
- (cl:mod number divisor)
- number - an integer or floating-point number
divisor - an integer or floating-point number
returns - the remainder of a cl:floor operation
(defun cl:mod (number divisor)
(if (= (abs number) (abs divisor))
(if (and (integerp number) (integerp divisor)) 0 0.0)
(let* ((i-quotient (/ (truncate number) (truncate divisor)))
(f-quotient (/ (float number) divisor))
(quotient (if (or (= i-quotient f-quotient) ; integer result
(not (minusp f-quotient)))
(truncate f-quotient)
(1- (truncate f-quotient)))))
(- number (* quotient divisor)))))
The cl:mod function performs the
cl:floor operation on its arguments and returns the
remainder of the cl:floor operation. The
result is either zero or an integer or floating-point
number with the same sign as the 'divisor' argument. If both
arguments are integer numbers, the cl:mod function is
equal to the mathematical modulus function.
Back to top
Nyquist / XLISP 2.0 -
Contents |
Tutorials |
Examples |
Reference