[Python-Dev] Rounding float to int directly ...

Nick Maclaren nmm1 at cus.cam.ac.uk
Tue Aug 1 15:12:38 CEST 2006

"M.-A. Lemburg" <mal at egenix.com> wrote:
> You often have a need for controlled rounding when doing
> financial calculations or in situations where you want to
> compare two floats with a given accuracy, e.g. to work
> around rounding problems ;-)

The latter is a crude hack, and was traditionally used to save cycles
when floating-point division was very slow.  There are better ways,
and have been for decades.

> Float formatting is an entirely different issue.

Not really.  You need controlled rounding to a fixed precision in
the other base.  But I agree that controlled rounding in binary
does not help with controlled rounding in decimal.

Nick Maclaren,
University of Cambridge Computing Service,
New Museums Site, Pembroke Street, Cambridge CB2 3QH, England.
Email:  nmm1 at cam.ac.uk
Tel.:  +44 1223 334761    Fax:  +44 1223 334679

More information about the Python-Dev mailing list