Decimal and Exponentiation
Tim Peters
tim.peters at gmail.com
Sat May 20 17:26:42 CEST 2006
[Raymond L. Buvel, on
http://calcrpnpy.sourceforge.net/clnumManual.html
]
> The clnum module handles this calculation very quickly:
>
> >>> from clnum import mpf
> >>> mpf("1e10000") ** mpf("3.01")
> mpf('9.9999999999999999999999932861e30099',26)
That's probably good enough for the OP's needs -- thanks!
OTOH, it's not good enough for the decimal module:
(10**10000)**3.01 =
10**(10000*3.01) =
10**30100
exactly, and the proposed IBM standard for decimal arithmetic requires
error < 1 ULP (which implies that if the mathematical ("infinite
precision") result is exactly representable, then that's the result
you have to get). It would take some analysis to figure out how much
of clnum's error is due to using binary floats instead of decimal, and
how much due to its pow implementation.
More information about the Python-list
mailing list