Is round() broken?

Joseph Wilhelm jwilhelm at outsourcefinancial.com
Wed Oct 31 15:49:18 EST 2001


Hello again everybody!

I'm having some troubles with round() now... either I'm doing it completely
wrong or round() is.  But here's what I'm getting.

>>> round( 43583.010000000002, 2 )
43583.010000000002
>>> round( 43583.010000000002 )
43583.0
>>> round( 43583.010000000002, 1 )
43583.0
>>> round( 43583.010000000002, 2 )
43583.010000000002
>>>

So, what this is saying.. is that rounding to 1 decimal point works... but
anything beyond that is broken?  Rounding negative will round the number
before the decimal point also.

And actually, as a side question.. that number was pulled from a float8
field in a Postgres database, using the 'pg' module. If I look at the field
through pgAdmin, I just see it as "43583.01", instead of that whole big long
decimal. Is it supposed to come out like this?

--Joseph Wilhelm





More information about the Python-list mailing list