相关疑难解决方法(0)

numpy数组中的整数溢出

import numpy as np
a = np.arange(1000000).reshape(1000,1000)
print(a**2)
Run Code Online (Sandbox Code Playgroud)

有了这段代码,我得到了这个答案.为什么我会得到负值?

[[         0          1          4 ...,     994009     996004     998001]
 [   1000000    1002001    1004004 ...,    3988009    3992004    3996001]
 [   4000000    4004001    4008004 ...,    8982009    8988004    8994001]
 ..., 
 [1871554624 1873548625 1875542628 ..., -434400663 -432404668 -430408671]
 [-428412672 -426416671 -424420668 ..., 1562593337 1564591332 1566589329]
 [1568587328 1570585329 1572583332 ..., -733379959 -731379964 -729379967]]
Run Code Online (Sandbox Code Playgroud)

python numpy

8
推荐指数
2
解决办法
3298
查看次数

标签 统计

numpy ×1

python ×1