Integer overflow in numpy arrays

前端 未结 4 611
执笔经年
执笔经年 2020-11-30 12:37
import numpy as np
a = np.arange(1000000).reshape(1000,1000)
print(a**2)

With this code I get this answer. Why do I get negative values?

         


        
4条回答
  •  日久生厌
    2020-11-30 13:28

    numpy integer types are fixed width and you are seeing the results of integer overflow.

提交回复
热议问题