[Numpy-discussion] Problems with long

Charles R Harris charlesr.harris@gmail....
Sat Jan 26 02:41:28 CST 2008


On Jan 26, 2008 12:39 AM, Tom Johnson <tjhnson@gmail.com> wrote:

> Hi, I'm having some troubles with long.
>
> >>> from numpy import log
> >>> log(8463186938969424928L)
> 43.5822574833
> >>> log(10454852688145851272L)
> <type 'exceptions.AttributeError'>: 'long' object has no attribute 'log'
>

Numpy uses the standard C functions, so can't represent very large integers
exactly. However, given the precision of the log function, it might be
reasonable to truncate the digits and write the Python long as a float
before conversion. That's what Python does.

In [6]: import math

In [7]: math.log(10454852688145851272L)
Out[7]: 43.793597916587672

In [8]: float(10454852688145851272L)
Out[8]: 1.045485268814585e+19

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080126/21d1ea60/attachment.html 


More information about the Numpy-discussion mailing list