On Wed, Sep 26, 2012 at 3:36 PM, M.-A. Lemburg <mal@egenix.com> wrote:
It's actually quite common in finance and time calculations to round to the nearest say basis point, cent or say micro second in calculations (rather than just string formatting). round() is perfect for that and easy to use.
Rounding to the nearest cent is an important operation, but it's not one that round really handles well. It certainly can't always round you exactly to the nearest hundredth--it can round you there with some inaccuracy when you're doing it to have an exact number. We have the decimal module (or sometimes just plain int) to handle this in a much more robust, correct way. I'm not personally familiar with the cases where one would want to round time like that for computations, but I can't help but suspect that if you want a quantity in a number of microseconds, you'd be wanting it to be exact as well. round only appears to be useful. Using it to try to get something "in cents" or similar is a strong code smell and probably a bug. Mike