[Python-3000] bug in modulus?

Aahz aahz at pythoncraft.com
Wed May 3 16:42:13 CEST 2006


On Wed, May 03, 2006, Antoine wrote:
> Le mercredi 03 mai 2006 ? 04:41 -0700, Michael Chermside a ?crit :
>> Tim Peters writes:
>>>
>>> IMO, it was a mistake (and partly my fault cuz I didn't whine early)
>>> for Python to try to define % the same way for ints and floats.
>>            [...]
>>> I'd like to see this change in Python 3000.  Note that IBM's proposed
>>> standard for decimal arithmetic (which Python's "decimal" module
>>> implements) requires two operations here, one that works like
>>> math.fmod(a, b) (exact and sign of a), and the other as described
>>> above (exact and |a%b| <= |b/2|).
>> 
>> So why not make "x % y" for floats behave exactly
>> like it does for integers
> 
> It already does :-)

Well, yes, but Uncle Timmy is jumping up and down and screaming for a
change.  Granted, I think we should show respect for our numerical
elders, but I think Michael also has a point about the importance of
making floats and ints behave the same, especially given that division
will auto-promote floats from ints.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"Argue for your limitations, and sure enough they're yours."  --Richard Bach


More information about the Python-3000 mailing list