+ 4

Someone explain me, how to work modulus ?

21st Jul 2017, 4:06 AM
Gp vishnu
Gp vishnu - avatar
3 Respuestas
+ 4
modulus is the remainder of division. for instance 5/2 2 goes into 5 twice and leaves a remainder of 1 so 5%2 is 1 if we had 19/5, 5 goes into 19 3 times and leaves a remainder of 4 so 19%5 is 4
21st Jul 2017, 4:22 AM
ChaoticDawg
ChaoticDawg - avatar
+ 2
modulu is reminder and addition example 37%5=2. with rest of 37-(5*7)=2
23rd Aug 2017, 6:59 AM
firoj
+ 1
It is good when trying to split numbers into categories. For example, seconds into hours, minutes and seconds. var time = 1253735; //seconds var hours = Math.floor(time / (24 * 60 * 60)); var minutes = Math.floor(time % (24 * 60 * 60) / (60 * 60)); var seconds = time % (24 * 60 * 60) % ( 60 * 60);
21st Jul 2017, 5:39 AM
James
James - avatar