+ 1
Im so confused
How does "%" work i understand the division and multiplication and stuff but what does the "%" do?
3 Antworten
+ 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.
+ 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
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.