0

What does %= do?

9th Aug 2016, 3:27 PM
Trygve Meyer Nibe
Trygve Meyer Nibe - avatar
4 Réponses
+ 1
a %= 5 its the same as a = a%5
9th Aug 2016, 4:52 PM
Or Batson
+ 1
its called the modulus operator. basically what you are saying is you want to get the remainder of the after you divider a number with another .. so x%=y is shortened version of x = x%y you can have +=, -=, /=
11th Aug 2016, 5:07 PM
Hacker Hacker
Hacker Hacker - avatar
0
I couldn't understand your answer can you explain it for me by onther example
11th Aug 2016, 10:29 AM
Rami Salim
Rami Salim - avatar
0
Consider this: a = 9; b = 3; a = a % b will store in the variable a the value 0, because a divided to b (3) has a reminder of 0. a %= b is the same as a = a % b. If b = 2, a = a % b will store in the variable a the value 1, because a divided to b (2) has a reminder of 1.
16th Aug 2016, 3:30 PM
Andrei Timofte
Andrei Timofte - avatar