long int computations
Mensanator
mensanator at aol.com
Tue May 4 12:50:47 EDT 2010
On May 3, 10:17 am, s... at sig.for.address (Victor Eijkhout) wrote:
> I have two long ints, both too long to convert to float, but their ratio
> is something reasonable. How can I compute that? The obvious "(1.*x)/y"
> does not work.
You could try using the gmpy module. It supports arbitrary precision
floats, so converting long to float is no problem.
YY = 3**10684
float(YY)
Traceback (most recent call last)
File "pyshell#78>", line 1, in <module>
float(YY)
OverflowError: Python int too large to convert to C double
import gmpy
gmpy.mpf(YY)
mpf('3.6600365709...0197681e5097',16936)
>
> Victor.
>
> --
> Victor Eijkhout -- eijkhout at tacc utexas edu
More information about the Python-list
mailing list