[docs] A possible Python bug.

Georg Brandl georg at python.org
Tue Oct 29 08:08:02 CET 2013


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am 24.10.2013 21:09, schrieb George R Goffe:
> Hi,
> 
> I seem to recall reading something about this a while ago but don't recall 
> exactly where.
> 
> I build Python 2.7 and 3.x from the repositories and both exhibit the same
> behavior:
> 
> 
> python Python 2.7.3 (default, Jul 24 2012, 11:41:40) [GCC 4.6.3 20120306
> (Red Hat 4.6.3-2)] on linux2 Type "help", "copyright", "credits" or
> "license" for more information.
>>>> 182.12-95.80
> 86.32000000000001
> 
> /tools/python/cpython# ./python Python 3.4.0a0 (default:f315fecdfeb8, Apr
> 6 2013, 13:13:19) [GCC 4.9.0 20130405 (experimental)] on linux Type "help",
> "copyright", "credits" or "license" for more information.
>>>> 182.12-95.80
> 86.32000000000001
> 
> the bc utility on my system produces what I would term the correct answer:
> 
> bc bc 1.06.95 Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free
> Software Foundation, Inc. This is free software with ABSOLUTELY NO
> WARRANTY. For details type `warranty'. 182.12-95.80 86.32
> 
> Am I missing something?
> 
> If this is a bug, I would be most willing to test any code changes that
> you might come up with.

Hi George,

this is an innate limitation of floating-point arithmetic.
Please have a look at http://docs.python.org/2/tutorial/floatingpoint.html
for an explanation of this behavior.

cheers,
Georg
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)

iEYEARECAAYFAlJvXtIACgkQN9GcIYhpnLBS1ACgiEwVQWFpgu8udACdwiZ6qRkw
7ikAoKFXpogxoEDImMlxN1bX3lk2872T
=xNk8
-----END PGP SIGNATURE-----


More information about the docs mailing list