Is this a bug?

John W. Baxter jwbaxter at spamcop.net
Sat Dec 29 00:36:06 EST 2001


In article <33e9b770.0112281857.563a36d4 at posting.google.com>, Gilbert
<blessed at mail.com> wrote:

> Hi!
> 
> I am wondering if the following results below imply any bug in Python
> 2.2 or 2.1?
> When I try to use float numbers, python 2.2 and 2.1.1 shows a little
> bit different results (I think it is incorrect) from what I enter. 
> But python 1.5.2 seems to be okay?  What is wrong?
> 
> If you know why and how they are different, please let me know.
> 
> Thanks!
> 
> -----------------------------------
> 
> Python 2.2 (#1, Dec 23 2001, 09:30:32) 
> [GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-98)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> 653.34
> 653.34000000000003
> >>>
> 
> -----------------------------------
> 
> Python 1.5.2 (#1, Oct 13 2001, 09:06:03)  [GCC 2.96 20000731 (Red Hat
> Linux 7.1 2 on linux-i386
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> >>> 653.34
> 653.34
> >>>

Python 1.5.2 is lying to you (by rounding off).  Later versions are
telling you the unpleasant truth.  653.34 doesn't exist in the
representation used.  [653.00, 653.25, 653.50, and 653.75 do
exist...the other 96 are approximated.]

YAPDFP

  --John



More information about the Python-list mailing list