+ 1
modulus
how does 7 mod 8 equal 7? my math is 7/8= .87 which rounds up to 1. Why would the answer not be 1? Is it because your left with 1 and that 1 -8=7?
3 Réponses
+ 4
Modulus isn't attempting to round up a decimal, it looks to return a natural number.
8 does not divide into 7 so you get a return of 7.
If you were dividing 8 into 9, you would get a return of 1 using modulus
+ 3
Modulo operator gives you remainder... So 7/8 gives quotient as 0 as it's integer division and remainder 7
+ 1
thanks