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.
-
Show this thread
-
Replying to @aaronmblevin
Is it negative parameters which get you? They get me.
1 reply 0 retweets 0 likes -
Replying to @propensive
no, but
@omarieclaire was just asking this to me and I had no idea how negatives work with modulo!1 reply 0 retweets 1 like -
Replying to @aaronmblevin @omarieclaire
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.
1 reply 0 retweets 1 like -
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.
11:44 AM - 30 Sep 2019
from Krakow, Poland
0 replies
0 retweets
0 likes
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.