Help me please : Rounding-down numbers

Tim Peters tim_one at email.msn.com
Wed Mar 26 22:21:38 EST 2003


[Joseph]
> I have a floating number which I need to "round-down" to the nearest
> whole number. I am doing this by type-casting it as an "int". Would
> this work all the time ? Or is there any instances when this will
> "round-up" ?

The question is clear enough.  What I'm unclear about is what you found
unclear in the docs for the int() function:

    http://www.python.org/doc/current/lib/built-in-funcs.html

and in particular what about

    Conversion of floating point numbers to integers truncates
    (towards zero)

did you read as leaving the question open?






More information about the Python-list mailing list