HN
Hacker News
Top
New
Best
Ask
Show
Jobs
Comment by notfish | Hacker News Reader
Parent
Full thread
notfish
·
Or just
x = x mod 10 y = y mod 10
View on HN
munificent
·
That depends on how the programming language implements modulo. Some don't wrap around the way you would need here when the dividend is negative. See:
https://en.wikipedia.org/wiki/Modulo#Variants_of_the_definit...
ithkuil
·
Would this work in both flavours of the modulo operator?
x = ((x mod 10) + 10) mod 10
Reply on news.ycombinator.com