[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

trunc



Warning: the definition of trunc in Common Lisp is not the same as an
integer divide instruction on most machines (except the S-1).  The
difference occurs when the divisor is negative.  For example, (trunc 5
-2) is defined to be the same as (trunc (/ 5 -2)) = (trunc -2.5) = -2,
whereas most machines divide such that the sign of the remainder is the
same as the sign of the dividend (aka numerator), which gives -3 for
5/-2.

Implementors should make sure that they do the appropriate testing
(ugh), unless someone wants to propose kludging the definition.