Math errors in python
Tim Peters
tim.peters at gmail.com
Mon Sep 20 07:50:50 CEST 2004
[Bengt Richter]
> ...
> If you add a small Decimal delta repeatedly, will it get rounded away like the
> floating point version,
Decimal *is* a floating-point type, containing most of IEEE 854 (the
radix-generalized variant of IEEE 754). It's got infinities, signed
zeroes, NaNs, ..., all that FP hair. Decimal specifies unnormalized
fp, though, so there's no special class of "denormal" values in
Decimal.
>or will accuracy get promoted,
No, but the number of digits of precision is user-specifiable. In all
places this makes sense, the result of an operation is the exact
(infinite precision) mathematical result, rounded once to the current
context precision, according to the current context rounding mode. If
you want 100 digits, ask for 100 digits -- but you have to ask in
advance.
More information about the Python-list
mailing list