0
Please explain me the difference between remainder and floor division.
For an example: If we do 37/10 , it shows the answer 3.7 .here the integer part is 3 and the remainder part is 7.we can also do it easily by writing this way: 37//10 and the ans will show 3. But 5/2 shows the result 2.5 so here we see the remainder part after the decimal 5. If we do that 5%2 , it always shows the remainder 1. So for the dividing method we can get the floor division easily but we can't get the remainder. So what's the problem in 5/2 that doesn't show the remainder correctly?
2 Respostas
+ 5
Both are valid mathematical functions with different results
The modulus-function(%) computes the remainder of a division, which is the "leftover" of an integral division.
The floor-function(//) provides the lower-bound of an integral division. The upper-bound is computed by the ceil function. (Basically speaking, the floor-function cuts off all decimals).
0
The remainder in 5%2 is shown correctly as is the result of 5/2. I will try to explain. You wrote yourself that 5/2 shows 2.5. That means the number 2 is in number 5 two and half times (basically 2*(2 + 1/2)). If you did 5//2 (in which the remainder wont show in the result) it would be 2 (5//2=2). Now, the difference between those numbers will be the remainder: 5 (the original number) - 2*2 (the number without reminder) = the remainder, which is number 1.
Did I understand stand your question correctly?