There is a confusing description of built-in function divmod()
,i post below:
If x is very close to an exact integer multiple of y, it’s possible for x//y to be one larger than (x-x%y)//y due to rounding. In such cases, Python returns the latter result, in order to preserve that divmod(x,y)[0] * y + x % y be very close to x.
x//y
should be equal to (x-x%y)//y
,according to the identity x == (x//y)*y
.I wonder how can x//y
be larger than (x-x%y)//y
when rounding occurred.