+ 3
Can someone explain me what's the difference between 4%2,4%-2,-4%2?why?
For the beginning,I used a wrong example which couldn't express my thought correctly.Now see 5%2,5%-2 and -5%2 instead.
3 Answers
+ 7
The answers for all three are zero. If you used 5%2,5%-2,-5%2, the answers are 1,1,-1. The sign of the 2 doesn't matter. The sign of the 5 is reflected in the result.
-5%2 can be thought of as 2 goes into -5 twice so remove -4 from it yielding -1.
+ 1
u are using modulus operator for 4 to 2 using different signs, here you take 2 as denominator to an even number so that all values beacome zero
if u replace any odd number to the divided by 2u get same answer but with sign which is used by u
for example take 9%2 quotient is 4 and remainder is 1 similarly 9%-2 quotient is -4 remainder is -1 hope u can understand this concept and thank u
+ 1
Its just division.A simple rule is that if the divisor is negative but not the dividend ,then the result is +ve(same sign as that of dividend) and vice versa for the other.