Decimal arithmatic, was Re: Python GUI app to impress the boss?

Tim Hoffman timh at zute.net
Wed Sep 25 09:30:11 EDT 2002


> 
> There ought to be severe penalties for idiots that use floating point
> dollars for financial applications.  If forced to use floating point
> (e.g. because customer demands BASIC), then keep money amounts in
> whole pennies (or whatever the smallest currency unit for the country
> is), and divide by 100 (or whatever) for printing only (or just add the
> decimal point yourself).
> 

In many circumstances this is exactly what you can't do.
The minute you need to calculate percentages you will get in to
the things like .0001254 of a cent, no matter what is you
smallest unit of currency.

I worked for a insurance company (using Business Basic) many
years ago on MAI and Prime gear, and we did everything as floats
with 14 places after the decimal point,and only rounded when
a human needed to see a number, and then used standard accounting
practices for rounding,

Rgds

Tim




More information about the Python-list mailing list