Rational Numbers

Hendrik van Rooyen mail at microcorp.co.za
Sat Jan 13 10:49:24 CET 2007


From: "Nick Maclaren" <nmm1 at cus.cam.ac.uk> wrote:

> Financial calculations need decimal FIXED-point, with a precisely
> specified precision.  It is claimed that decimal FLOATING-point
> helps with providing that, but that claim is extremely dubious.
> I can explain the problem in as much detail as you want, but would
> very much rather not.

Ok I will throw in a skewed ball at this point - use integer arithmetic,
and work in tenths of cents or pennies or whatever, and don't be too 
lazy to do your own print formatting...

To represent $121.23 as a float is just asking for trouble when you
are trying to deal with something that can take a value like:

$123 456 789 012 345 678 901.07  - and you are worried about the 
seven cents for accounting purposes...

Remember that its not only money that is measured like that, but 
debt too...

-Hendrik




More information about the Python-list mailing list