News for hackers. Stuff that matters.
Re:Mod and remainder are not the same by Skeime on Friday August 24, 2018 @09:55AM (#17834934)
Grandparent here: I know, that’s what I tried to explain (poorly) with the next sentences. Programming languages with a remainder operator choose two representatives for every equivalence class except [0] and return the one that has the same sign as the dividend.

I tend to define

  mod = (a, b) => (a % b + b) % b
because it works without going through floats – in languages that have integer types. I don’t know if there are actual advantages though.

There are no comments on this comment yet.