News for hackers. Stuff that matters.
Re:Low Level Bit Hacks You Absolutely Must Know by kazinator on Friday May 11, 2018 @10:43AM (#17047619)
ISO C doesn't leave it up to the hardware. Integer division is required to truncate toward zero; the remainder harmonizes with that. (If someone designs a new HLL which leaves some arithmetic to the hardware that C doesn't, that is indeed silly.)

The sane language here Common Lisp: it does it in all the ways rather than picking one approach with some hand-waving justification about why it's the good choice.

It has truncate, round, ceiling and floor functions that all return a quotient and remainder.

There are also mod and rem functions that calculate just the remainder from a floor and truncate, respectively.

There are no comments on this comment yet.