Rounding up to the next 100
Alf P. Steinbach
alfps at start.no
Thu Jan 21 23:20:08 CET 2010
> Sorry, although what I really need is the string-number rounded UP
> every time. So if the number is 3890.32, it needs to go to 3900; if
> the number is 3811.345, it needs to go to 3900 also.
> So, Florian's answer works.
You might also consider
Which avoids the math.ceil but assumes the number is positive (or zero).
Cheers & hth.,
PS: Note that this trick doesn't work with most other common languages that I'm
familiar with, since the round towards zero instead of down to minus infinity,
but Python has more clean semantics in this regard.
More information about the Python-list