[BangPypers] why is round() not working?
pasokan at gmail.com
Fri Feb 19 08:28:03 CET 2010
On Fri, Feb 19, 2010 at 12:37 PM, Kenneth Gonsalves <lawgon at au-kbc.org> wrote:
> what gives?
You are running into the problems of floating point number
representation. This has nothing to do with round()
>>> x = 2.17
The number displayed is the best representation given the binary
representation's limits of storage etc., Some languages (Ruby comes to
mind) display 'better' looking results and IIRC Python 3 will also do
>> x = 2.17
If you are looking at displaying, consider doing sth. like
>>> print "%5.3f" %(round(2.16670000001, 3))
We will find a way. Or, make one. (Hannibal)
More information about the BangPypers