This math scares me
sholden at holdenweb.com
Wed Mar 14 01:18:53 CET 2001
"Grant Edwards" <grante at visi.com> wrote in message
news:yTwr6.1235$Tg.167429 at ruti.visi.com...
> In article <jwbnews-09D75F.13313313032001 at corp.supernews.com>, John W.
> >In article <984518199.127140 at newsmaster-04.atnet.at>,
> > "Werner Schiendl" <ws-news at gmx.at> wrote:
> >> True, but even 0.1 and 0.2 need not necessarily be exact values.
> >Of the single decimal digit numbers, 20% are exact (x.0 and
> >x.5, for not huge x). For two decimal places, it's down to 4%
> >(x.00, x.25, x.50, x.75) and it spirals quickly downward from
> >Bill Gates got this right in the early days, delivering two
> >Basic interpreters: binary floating point for speed, and
> >decimal floating point for money and such. (I never looked at
> >how well his interpreters did...I just used them.)
> I don't know if you can credit Gates with doing anything other
> than following the pack. Back when I first started doing
> software (CP/M 1.7), all language packages for "personal"
> computers came with both BCD and binary FP math libraries so
> you could do exact monetary calculations if you wanted.
> Of course we'd never imagined we'd ever see hardware FP and BCD
> libraries were only marginally slower than binary ones. Now
> that FP is usually in hardware, BCD FP (or fixed point) will be
> pretty slow by comparison.
For monetary calculations none of this really matters. As long as you round
to 2 decimal places after each calculation the rounding error never gets bif
enough to bother about. And, of course, BCD is pretty fast on machines (such
as mainframes) which have hardware support for it built in. Maybe we need a
library we can use for BCD when running Linux under MVS.
or-is-that-VMS-ly y'rs - steve
More information about the Python-list