The
| the result of truncating the result of number divided by divisor | ||
| the remainder of the truncate operation |
(defun cl:floor (number &optional (divisor
(if (integerp number) 1 1.0)
divisor-p))
(let ((quotient
(cond ((and (not divisor-p) (integerp number)) number)
((= number divisor) 1)
(t (let ((i-quotient (/ (truncate number) (truncate divisor)))
(f-quotient (/ (float number) divisor)))
(if (or (= i-quotient f-quotient) ; integer result
(not (minusp f-quotient)))
(truncate f-quotient)
(1- (truncate f-quotient))))))))
(setq *rslt* (list quotient (- number (* quotient divisor)))
cl:*multiple-values* t)
quotient))
The
The quotient is directly returned by the function, while a list:
(quotient remainder)
is stored in the Nyquist/XLISP *rslt* variable and the cl:*multiple-values* is set to T to signal that Multiple Values are returned.
Examples:
(cl:floor 3.5) => 3 ; *rslt* => ( 3 0.5) (cl:floor -3.5) => -4 ; *rslt* => (-4 0.5)
See also: