hi i am a mathemagician and vaguely experienced programmer of many years and i still get confused about which goes where whenever i use the modulo operator (%). i'm always dropping into the console or REPL to remind myself.
Basically there are two reasonable interpretations of a%b for negative a, though I always want the one which Java doesn't use, and I've forgotten why the one it does use is reasonable.
-
-
This Tweet is unavailable.
-
Option 1: (-a)%b = -(a%b) Option 2: (a + kb)%b = a%b for all integers, a, b, k I always want option 2. For example, I want (-1)%5 = 4.
End of conversation
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.