[Numpy-discussion] negative numbers

Slavin, Jonathan jslavin at cfa.harvard.edu
Tue Jan 29 08:38:07 EST 2019


I'm not sure which numpy version you're using (I don't get that using numpy
1.14.3), but the issue is that for some reason the data type (dtype) of the
array is being assumed to be a 4 byte integer or '<i4'. The maximum value
for that is 2,147,483,647 whereas 1999**3 = 7,988,005,999. To get the
correct result you can specify the dtype:
a = np.arange(2000,dtype='<i8')**3
for example.

Regards,
Jon

On Tue, Jan 29, 2019 at 2:54 AM <numpy-discussion-request at python.org> wrote:

> From: Yuping Wang <wyupinghhu at 163.com>
> To: numpy-discussion at python.org
> Cc:
> Bcc:
> Date: Tue, 29 Jan 2019 15:22:00 +0800 (CST)
> Subject: [Numpy-discussion] Numpy-discussion
> Dear Nmupy developers and users:
>         I am a new user of Numpy ,I have encountered a question about
> Numpy recently, which need your help. The question is below:
>
>
>
>
>      I don  know why there are negative numbers
>      can somebody explain to me why these happens
>     Thanks in advance!
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
>


-- 
Jonathan D. Slavin
Astrophysicist - High Energy Astrophysics Division
Center for Astrophysics | Harvard & Smithsonian
Office: (617) 496-7981 | Cell: (781) 363-0035
60 Garden Street | MS 83 | Cambridge, MA 02138
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20190129/9a5622ac/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ??.JPG
Type: image/jpeg
Size: 34523 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20190129/9a5622ac/attachment-0001.jpe>


More information about the NumPy-Discussion mailing list