> asa side effect, I happened to observe the following rounding bug. > It happens in Stackless Python, which is built against the > pre-unicode CVS branch. > > Is this changed for 1.6, or might it be my bug? > > D:\python\spc>python > Python 1.5.42+ (#0, Mar 29 2000, 20:23:26) [MSC 32 bit (Intel)] on win32 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> round(3.1415926585, 4) > 3.1415999999999999 > >>> ^Z > > D:\python>python > Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> round(3.1415926585, 4) > 3.1416 > >>> ^Z This is because repr() now uses full precision for floating point numbers. round() does what it can, but 3.1416 just can't be represented exactly, and "%.17g" gives 3.1415999999999999. This is definitely the right thing to do for repr() -- ask Tim. However, it may be time to switch so that "immediate expression" values are printed as str() instead of as repr()... --Guido van Rossum (home page: http://www.python.org/~guido/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4