Reputation: 19
I got a weird result from one of my codes and I went through every line on it until I found that the product of two positive numbers is giving a negative result, using Python (through Spyder)
areaim=np.array([130*180,132*177,358*344,361*336,362*337,362*337,362*338,362*339,365*343])
area=np.sum(areaim)
air=74*16*1000
air*area
Out[29]: -1666528000
This problem can be solved by converting the numbers into floats, but I'd like to know what is happening. Is it an overflow problem similar to what it happens in other languages?
Upvotes: 1
Views: 740
Reputation: 16660
While integers in Python cannot overflow, because they have arbitrary size, integers from numpy can. Therefore it is an overflow.
You can get more explanations from here.
Upvotes: 3