This math scares me

Tim Peters tim.one at home.com
Mon Mar 19 21:44:43 EST 2001


[Terry Reedy]
> BCD does not eliminate the problems of finite precision arithmetic.

[Greg Ewing]
> No, but it lets you see exactly what's going on
> in terms that most people are familiar with. It
> eliminates any *extra* surprises due to conversion
> between bases.

In addition, due to the lack of any sort of BCD support in C, any form of BCD
support in Python would most likely be coded via general multiprecision
algorithms.  Meaning you could conceivably boost the precision up to the
limits of memory.  This is very effective in the REXX language:  if your
results look fishy, rerun the program with (say) twice the precision, and see
whether the results agree up to the original precision.  If not, you're
suffering a numeric surprise *somewhere*, and where the two runs start to
diverge is a great clue as to where; or, if they do agree, your original
results were either OK or you're suffering a very unlucky fp surprise.

The original Cray Fortran compiler supported that gimmick "in reverse":  a
compile switch caused each (binary) fp result to get *truncated* to N bits (a
simply masking operation).  Non-experts loved it:  via plotting results
versus number of bits, unstable algorithms often stuck out like a broken
nose.

cleaning-up-the-blood-was-a-bit-unpleasant-though-ly y'rs  - tim





More information about the Python-list mailing list