Re: [Numpy-discussion] NumPy-Discussion Digest, Vol 148, Issue 27

2019-01-29 Thread Yuping Wang
I start to learn python from 《Numpy Beginner's Guide》second edition written by Ivan Idris now I know what the problem is ,the reason is that Numpy converts 2000 to an `int32`.When I use code `a=np.arange(2000, dtype='int64')**3 that you taught me, the calculation is correct thank you all ! Yu

Re: [Numpy-discussion] Numpy-discussion

2019-01-29 Thread Chris Barker - NOAA Federal
> On Jan 29, 2019, at 12:15 AM, Matti Picus wrote: >> Perhaps you could suggest they add this explanation (or if it is in our >> documentation point out where you think would be appropriate) since it seems >> many people have problems with dtypes and overflow. arange() is particularly problem

Re: [Numpy-discussion] negative numbers

2019-01-29 Thread Slavin, Jonathan
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 ' wrote: > From: Yuping Wang > To: numpy-discussion@python.org > Cc: > Bcc: > Date: Tue, 29 Jan

Re: [Numpy-discussion] Numpy-discussion

2019-01-29 Thread Stefan van der Walt
On Tue, 29 Jan 2019 10:15:00 +0200, Matti Picus wrote: > 2000*2000*2000 overflows a 32 bit signed integer, so it wraps around to a > negative value. I was curious about what happens, bit-wise, in this case. We are dealing with a signed integer, so I presume of the 33 bits in 2000**3, only 32 are

Re: [Numpy-discussion] Numpy-discussion

2019-01-29 Thread Matti Picus
On 29/1/19 9:22 am, Yuping Wang wrote: 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

Re: [Numpy-discussion] Numpy-discussion

2019-01-29 Thread Kirit Thadaka
You are seeing negative numbers because of an overflow beyond 32 bits. Change the type of your np array to int64 using a = (np.arange(2000) ** 3).astype(np.int64) and you won’t see negative numbers. I assume you are running this code on a 32 bit machine which is why Numpy is defaulting to int32