r/learnjava • u/[deleted] • Oct 30 '16
What the HELL is a modulo?
I have a test tomorrow, in the test one of the questions will be to seperate a number from a 3 digit number, say I have 641, I need to know how to print out 6,4 and 1 seperately.
What the hell do I do ? The teacher is so bad I couldn't understand a word she said and neither did my class, we already complained about her but this isn't the issue, the issue is that I have no easy answers on the internet for what the modulo is.
Why does doing (n/100)%10; print out the hundred digit ? I have no idea how this works, please go easy on me.
0
Upvotes
1
u/Blackheart595 Oct 30 '16
7 % 3 == 1. That's because7 / 3 == 2if you round the result down, but2 * 3 == 6, so there's still 1 missing. Similarily,18 % 7 == 4because18 == 2 * 7 + 4.Actually, as you seem to have some difficulties with English, try reading these wikipedia articles here and here in your language, it will probably explain everything you need.