0

# 1.25 % 0.5 = 0.25, shouldn't it be 0.5?

So I'm a bit unclear of how the % works If I understand it correctly, basically what it does is 1.25/0.5, and then print out the reminder But 1.25/0.5 is 2.5, so wouldn't the reminder be 0.5?

2 Answers

+ 5

% is modulus operator, returns remainder.
1.25/0.5=2.5
BUT for modulus, you should not take any decimals,since that would return remainder 0 in each case.
1.25=2*0.5 + 0.25
0.25 is the remainder.

+ 5

and you are saying 0.5 ,how did you get it???
1.25/0.5 = 2.5 ,means remainder is 0