+ 3

Javascript learn

Can someone explain me better how modulus works? or I'm so stupid that I don't understand it

16th Feb 2017, 9:18 PM
Jakub Adamski
Jakub Adamski - avatar
4 Answers
+ 20
25 % 3... First do 25 / 3. you will get something around 8.3 . Then 8 * 3 = 24, you multiply the integer with the number that the original has been divided to. Then you take away 24 from 25, so that will leave 1. So basically, modulus gives the remainder of a division
16th Feb 2017, 10:51 PM
Gami
Gami - avatar
+ 10
It gives you the remainder of the inerger division, for example 5%2 : as 5/2 is 2 because it doesn't have decimals, 2*2=4 so the remainder is 1. So 5%2=1, same thinking would apply for all, like 9%4=5 for ex
16th Feb 2017, 10:47 PM
C.E.
C.E. - avatar
+ 9
you see how many times it fits inside the number and the rest it's the answer
16th Feb 2017, 10:47 PM
C.E.
C.E. - avatar
+ 8
9%4=1
17th Feb 2017, 3:21 AM
Torbjørn
Torbjørn - avatar