long int computations

Paul Rubin no.email at nospam.invalid
Thu May 6 02:55:23 EDT 2010


see at sig.for.address (Victor Eijkhout) writes:
> 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.

The math.log function has a special hack for long ints, that might help:

    Python 2.6.2 (r262:71600, Jan 25 2010, 18:46:47) 
    >>> from math import *
    >>> a = log(3**100000)
    >>> a
    109861.22886681097
    >>> b = log(3**100001)
    >>> exp(b-a)
    2.9999999999994813



More information about the Python-list mailing list