- 1
1.25%0.5 give the output. .
15 odpowiedzi
+ 2
1.25 % 0.5 = 0.25
Because 1.25 / 0.5 = 2
And 1.25 - 0.5 * 2 = 0.25
+ 1
0.25. % is the remainder (or modulus) operation, it divides the 2 numbers and gives the remainder
+ 1
How?
+ 1
It must be 0.
+ 1
No.
+ 1
Why?
+ 1
I just explained.
+ 1
How ?there must be no remainder
+ 1
1.25 / 0.5 equals 2. 1.25 - (2 * 0.5) equals 0.25.
+ 1
I m not able to understand it
+ 1
Well, it is 3rd grade math. You will subtract 0.5 from 1.25 until you reach 0. 1.25 - 0.5 = 0.75, 0.75 - 0.5 = 0.25. You can't go further, so the remainder is 0.25
+ 1
In your particular case the Modulus operation checks how often 0.5 fits into 1.25 as Airree said. It fits in 2 times (2 * 0.5 = 1.0) and 0.25 are remaining
+ 1
Can't we go for 125/50?
+ 1
125/50 would do 2.5
125%50 will result in 25
+ 1
Can't we go for normal division here?