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?
numpy integer types are fixed width and you are seeing the results of integer overflow.