2 ms·
The direction of modulo with negative operands (and of division) was implementation-defined in C90. At least it is pinned down now. Common Lisp has a number d
by kazinator 7y ago
The direction of modulo with negative operands (and of division) was implementation-defined in C90.
At least it is pinned down now.
Common Lisp has a number different modulo operators that go every which way.
Firstly there are the single-valued mod and rem:
http://clhs.lisp.se/Body/f_mod_r.htm http://clhs.lisp.se/Body/f_mod_r.htm
Secondly, the floor, ceiling, truncate and round functions also return a remainder:
http://clhs.lisp.se/Body/f_floorc.htm http://clhs.lisp.se/Body/f_floorc.htm