Decimal arithmetic, with example code

Tim Peters tim_one at email.msn.com
Wed Oct 2 05:22:16 CEST 2002


[Bengt Richter]
> This is unproved, but maybe with the help of timbot et al we can prove
> the range over which is is safe and useful. The test run doesn't prove
> anything, but I thought it interesting. Just run it as you would
> your version.

Note that you have no control over the accuracy of operations like 10.00**i,
or of % formats, because Python has no control over them -- they're
delegated to the platform libm pow() and libc sprintf(), and the quality of
those varies massively across platforms.  If you want to be safe, you can't
leave such things to the competency of your platform library writers.
Floating divmod is also a bitch, limited by the quality of the platform
fmod().

I'm unclear on why so many are defending binary fp to people who insist they
don't want it.  It's not like binary fp is in danger of going away in our
lifetimes -- this is like "defending" Perl against Python <wink>.

every-numeric-scheme-sucks-for-some-apps-and-you're-always-better-off-
    using-one-that-doesn't-obviously-suck-for-yours-ly y'rs  - tim





More information about the Python-list mailing list