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

cl:rem


(cl:rem number divisor)
number - an integer or floating-point number
divisor - an integer or floating-point number
returns - the remainder of a cl:truncate operation

(defun cl:rem (number divisor)
  (if (= (abs number) (abs divisor))
      (if (and (integerp number) (integerp divisor)) 0 0.0)
      (let ((quotient (truncate (/ (float number) divisor))))
        (- number (* quotient divisor)))))

The cl:rem function performs the cl:truncate operation on its arguments and returns the remainder of the cl:truncate operation. The result is either zero or an integer or floating-point number with the same sign as the 'number' argument. If both arguments are integer numbers, the cl:rem function is equal to the mathematical remainder function.

  Back to top


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