A modest PEP0238 suggestion

Chris Barker chrishbarker at home.net
Wed Jul 25 13:36:04 EDT 2001


Guido van Rossum wrote:

>Changing 1/2
> from returning a float to returning a rational won't have to break
> code, since the mathematical value of the result is the same.

No, it's not. We should all be aware now that 1/10 as a rational is not
the same value as 1/10 stored as binary floating point. After all, how
many times does someone post a question about why a loop like the
following doesn't terminate?

>>> i = 0.
>>> while i <> 1:
...     i+=0.1


Anyway, while the difference is far more subtle, and far less likely to
break code, a rational is NOT a float (nor is a float a real, so I'm
glad you didn't name them that). And there are a few of us that
occasionally make use of or at least accomodate the difference (not to
mention performance issues!)

-Chris


-- 
Christopher Barker,
Ph.D.                                                           
ChrisHBarker at home.net                 ---           ---           ---
http://members.home.net/barkerlohmann ---@@       -----@@       -----@@
                                   ------@@@     ------@@@     ------@@@
Oil Spill Modeling                ------   @    ------   @   ------   @
Water Resources Engineering       -------      ---------     --------    
Coastal and Fluvial Hydrodynamics --------------------------------------
------------------------------------------------------------------------



More information about the Python-list mailing list