3 ms·
Or just x = x mod 10 y = y mod 10
by notfish 3y ago
Or just
x = x mod 10
y = y mod 10
- munificent 3y agoThat 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_definition https://en.wikipedia.org/wiki/Modulo#Variants_of_the_definit...
- ithkuil 3y agoWould this work in both flavours of the modulo operator? x = ((x mod 10) + 10) mod 10