[FRPythoneers] Numerical Accuracy

Evelyn Mitchell efm at tummy.com
Sat May 18 13:44:45 MDT 2002


It's definately related to a problem with 29.8:

Python 2.2 (#1, Apr 12 2002, 15:29:57)
[GCC 2.96 20000731 (Red Hat Linux 7.2 2.96-109)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 29.8+2.5+4*1.5
38.299999999999997
>>> 4*1.5
6.0
>>> 29.8+2.5
32.299999999999997
>>> 29.8+2.5+6.0
38.299999999999997
>>> 29.8+6.0
35.799999999999997
>>> 2.5+6.0
8.5
>>> 8.5+29.8
38.299999999999997
>>> 29.8
29.800000000000001

Looks like a bug to me.


* On 2002-05-18 19:26 Keith Hellman <kehellman at yahoo.com> wrote:
> Hello all:
> 
> I just typed the following and was surprised at the result.  Can someone
> point me to documentation concerning why this is?  Particularly, I'm
> curious why the identical parsing and computation yields an accurate 38.3
> in both /usr/bin/bc and a simple C program.
> 
> Do I need additional syntax to reduce error for floating calculations?
> 
> TIA
> 
> =====================================================================
> khellman at linux:~> python                     
> Python 2.2.1c2 (#1, Apr  8 2002, 13:32:43) 
> [GCC 2.95.3 20010315 (SuSE)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> 29.8+2.5+4*1.5
> 38.299999999999997
> >>> 29.8+2.5+(4*1.5)
> 38.299999999999997
> >>>
> =====================================================================
> 
> =====
> Keith E. Hellman
> kehellman at yahoo.com
> 
> __________________________________________________
> Do You Yahoo!?
> LAUNCH - Your Yahoo! Music Experience
> http://launch.yahoo.com
> _______________________________________________
> This message sent by the FRPythoneers mailing list.
> Unsubscribe: echo unsubscribe | FRPythoneers-request at lists.community.tummy.com
> URL: http://lists.community.tummy.com/mailman/listinfo/frpythoneers

-- 
Regards,                    tummy.com, ltd 
Evelyn Mitchell             Linux Consulting since 1995
efm at tummy.com               Senior System and Network Administrators
                            http://www.tummy.com/



More information about the FRPythoneers mailing list