[Python-3000] bug in modulus?
Christophe
chris.cavalaria at free.fr
Wed May 3 05:29:35 EDT 2006
Guido van Rossum a écrit :
> This is way above my head. :-)
>
> The only requirement *I* would like to see is that for floats that
> exactly represent ints (or longs for that matter) the result ought of
> x%y ought to have the same value as the same operation on the
> corresponding ints (except if the result can't be represented exactly
> as a float -- I don't know what's best then).
Which is exactly the case at hand.
As a proposed change, I would say that when the implementation of x%y
returns y, then we should return 0 instead, or maybe the biggest
possible number that is still < y. That way we would have a result that
respects the "x%y < y" rule and still be as good as possible with the
reduced float precision.
And besides, mathematics say that "0 = y = 2y = 3y [y]" and so there is
no problem for returning 0 instead of y :)
More information about the Python-list
mailing list