creating array using numpy from 1 to 100000 as value of x and y = x*x
x = np.arange(1,100000)
y = x*x
but when checked y value there are 31k negative value
count = 0
for i in y:
if i < 0:
count =1
print(count)
31612
CodePudding user response:
You are probably having integer overflow, try convert x
to float before raising the power:
x = np.arange(1,100000)
y = x**10
sum(y < 0)
49760
Convert to float:
x = np.arange(1,100000).astype(float)
y = x**10
sum(y < 0)
0