Where is the correct round() method? Use math.ceil
sorsorday at gmail.com
Mon Jul 28 02:35:08 CEST 2008
> Where is the correct round() method?
> I need a round function that _always_ rounds to the higher integer if
> the argument is equidistant between two integers. In Python 3.0, this
> is not the advertised behavior of the built-in function round() as
> seen below:
> >>> round(0.5)
> >>> round(1.5)
> >>> round(2.5)
> I would think this is a common need, but I cannot find a function in
> the Python library to do it. I wrote my own, but did I miss such a
> method in my search of the Python library?
Use ceil in the math module:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list