[NumPy-Tickets] [NumPy] #1629: np.prod returns 0 in case of integer overflow
NumPy Trac
numpy-tickets@scipy....
Sat Oct 9 19:34:24 CDT 2010
#1629: np.prod returns 0 in case of integer overflow
--------------------+-------------------------------------------------------
Reporter: kilian | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: Unscheduled
Component: Other | Version: 1.4.0
Keywords: |
--------------------+-------------------------------------------------------
Comment(by charris):
I don't see this for current svn on my 64 bit system:
{{{
In [3]: array([2**16,2**16]).prod()
Out[3]: 4294967296
In [4]: array([2**16,2**16]).prod(dtype=int64)
Out[4]: 4294967296
In [7]: array([2**16,2**16]).dtype
Out[7]: dtype('int64')
}}}
However, it could be that the default accumator on your system is int32?
What platform are you on? In any case, you should specify the type of the
result, numpy can't tell in advance how big the product is going to be and
it could easily be out of range for anything but arbitrary precision
integers.
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1629#comment:1>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list