Decimal and Exponentiation

Raymond L. Buvel levub137 at
Sat May 20 13:07:11 CEST 2006

Tim Peters wrote:

> The GNU GMP library (for which Python bindings are available) also
> supports "big floats", but their power operation is also restricted to
> integer powers and/or exact roots.  This can be painful even to try;
> e.g.,
>    >>> from gmpy import mpf
>    >>> mpf("1e10000") ** mpf("3.01")
> consumed well over a minute of CPU time (on a 3.4 GHz box) before dying
> with
>    ValueError: mpq.pow fractional exponent, inexact-root

The clnum module handles this calculation very quickly:

>>> from clnum import mpf
>>> mpf("1e10000") ** mpf("3.01")
>>> x=_
>>> x ** (1/mpf("3.01"))


More information about the Python-list mailing list