+ 1

Im so confused

How does "%" work i understand the division and multiplication and stuff but what does the "%" do?

23rd Jan 2017, 5:10 AM
Ciege2500
Ciege2500 - avatar
3 Answers
+ 2
While yes, the % is the remainder of two numbers, i like to think of it as a way to loop through values. So for example, take 7%3 now first of all take 7-3 which is 4 but thats not far enough, so again 4-3 and get 1. So in essence the second number is the MAX that the first can be, so just keep taking away the sexond number from the first until it fits.
23rd Jan 2017, 6:18 AM
Kolton Hahn
Kolton Hahn - avatar
+ 1
it is a binary modulas operator, syntax: num1 % num2 , return the remainder obtained when num1is divided by num2 e.g 4%3 =1 8%6=2
23rd Jan 2017, 5:41 AM
Ravi Kumar
Ravi Kumar - avatar
0
I'm more confused after reading the responses. The examples you used, Ravi, make it look as though the % symbol is no different than the - symbol, which I'm guessing isn't the case.
28th Jan 2017, 7:18 PM
Sam Heffner