Decimal and Exponentiation
Raymond L. Buvel
levub137 at wi.rr.com
Sat May 20 18:25:33 CEST 2006
Tim Peters wrote:
> [Raymond L. Buvel, on
>> The clnum module handles this calculation very quickly:
>> >>> from clnum import mpf
>> >>> mpf("1e10000") ** mpf("3.01")
> 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) =
> 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.
Indeed, it is not clear where the error is comming from especially since
you can increase the precision of the intermediate calculation and get
the exact result.
>>> mpf(mpf("1e10000",30) ** mpf("3.01",30), 20)
Is this the kind of thing you will need to do in the Decimal module to
meet the specification?
More information about the Python-list