monetary applications (et al)
chironsw at swbell.net
Thu Sep 19 20:06:57 CEST 2002
> Out of curiousity, does python have any standing in the field of
> business accounting? Perhaps those with experience can chime in as to
> how this has been handled effectively. We learned long ago to keep all
> amounts in whole pennies.
The original poster was asking about "currency", which implies a need to
store, and possibly to convert between, different currencies. A
generic currency class could reasonably store values as long integers,
representing the smallest indivisible unit within a given currency (i.e.
American cents, English pence, French centimes, Israeli agorot, Afghani
puls, etc), along with the number of subunits in the whole (usually 100,
but there are exceptions, such as 1000 fils in an Iraqi dinar, or 5
khoums in a Mauritanian ouguiya).
On the other hand, cents aren't really indivisible in the American
marketplace, where stock prices often change by fractions of a dollar,
as in "General Motors down 2 and 1/8".
As always, the class you build is determined by the use you to which you
intended to put it.
More information about the Python-list