0
heeeeelp! why is 1.25%0.5=0.25?????
10 odpowiedzi
+ 9
1.25 mod 0.5 = 0.25
1.25 = 0.5 + 0.5 + 0.25
+ 3
'%' gives the remainder as the answer whereas '/' gives the quotient.
+ 2
1.25/0.5=2 rest 0.25 <------
0
% gives reminder
0
why isn't 0.5?
0
0.5)1.25(2
1
0.25 (After Subracting 1.25 with 1)
0
'%' is not equal to '/'
0
0.25
0
IF anyone remembers doing long division by hand (back when you had to walk to school uphill, both ways, in the snow).
.5⟌1.25
.5 goes into 1 2 times (.5*2 = 1)
2
.5⟌1.25
-1.00
.25
when you subtract the 1 from 1.25, you get the REMAINDER which is .25. That is what the modulo "%" is referring to.
If you do regular division of "how many times does .5 go into 1.25", that is 2.5, and where I personally was confused to begin with.
Funny that you have to go old school to learn new code. :)
0
Simple.
How many half (0.5) in the 1 and quarte (1.25)?
The answer is there 2 halfs (0.5 0.5) in the one and quarter (1.25)
But when we add 0.5 to 0.5 it will equal one only 1!! not 1.25.
So 0.25 are remaining
So % means how much are remaining when we count how many 0.5 inside the 1.25.