[Numpy-discussion] log can't handle big ints

Travis Oliphant oliphant.travis at ieee.org
Wed Aug 16 14:20:43 CDT 2006

David Grant wrote:
> I am using numpy-0.9.8 and it seems that numpy's log2 function can't
> handle large integers?
> In [19]: a=11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
> In [20]: math.log(a,2)
> Out[20]: 292.48167544353294
> In [21]: numpy.log2(a)

Ufuncs on objects (like the long object) work by looking for the 
corresponding method.  It's not found for long objects.

Convert the long object to a float first.   I'm not sure of any other 
way to "fix" it.  I suppose if no method is found an attempt to convert 
them to floats could be performed under the covers on all object array 


More information about the Numpy-discussion mailing list