Decimal arithmatic, was Re: Python GUI app to impress the bos s?
tdelaney at avaya.com
Thu Sep 26 01:50:41 CEST 2002
> From: danb_83 at yahoo.com [mailto:danb_83 at yahoo.com]
> "Stuart D. Gathman" <stuart at bmsi.com> wrote in message
> news:<amo0aq$5nf$1 at nntp2-cm.news.eni.net>...
> > 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).
> That's exactly how things were done at my old workplace, except that
> cents were also used for user input. Most of the time.
It's called Fixed Point arithmetic, and strangely enough, Tim Peters wrote
an excellent implementation ...
More information about the Python-list