floating Pt. Division errors in Windows 2000

Chris Barker chrishbarker at home.net
Fri Nov 30 15:15:45 EST 2001


Leon Webster wrote:
> When I execute this on my laptop (win2k machine, pentium III), I get the
> following answer:
> 
> 0.80000000000000004
> 
> The same program on Linux provides the right answer (0.8), as does a program
> written in Java.

not, it doesn't. From my Linux box:
>>> a = 3
>>> b = 4
>>> b/(2.0 + a)
0.80000000000000004

The difference is probably an older version of Python, not Linux vs.
Win2k. Older versions of Python rounded the result displayed in the
interpreter for you to make it look more pretty. The same is probably
true for your JAVA program.


-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