is int(round(val)) safe?
Steven Bethard
steven.bethard at gmail.com
Mon Nov 22 16:33:23 EST 2004
Peter Hansen wrote:
> Since round() returns an integer
Just to clarify in case anyone else misreads this, I belive the intent
here was to say that round(f) -- that is, round with only a single
argument -- returns a floating point number with no fractional component
after the decimal point. The result is still a float, not an int though:
>>> round(3.14159265359)
3.0
>>> round(3.14159265359, 2)
3.1400000000000001
I think the intent was clear from the rest of the post, but I figured it
wouldn't hurt to clarify this for any newbies who misread it like I did.
Steve
More information about the Python-list
mailing list