Reputation: 8609
When divide different dividends by zero, I got different results.
arr = np.array([0.0, 1.0, -0.1])
print(arr/0)
The results are following
[ nan inf -inf]
Why? I expect the results were all nan
.
BTW, I got two types of warning.
__main__:1: RuntimeWarning: divide by zero encountered in divide
__main__:1: RuntimeWarning: invalid value encountered in divide
Upvotes: 2
Views: 2246
Reputation: 188
IEEE 754 defines division by zero as follows:
a ÷ +0 is positive infinity when a is positive, negative infinity when a is negative, and NaN when a = ±0.
Source: https://en.wikipedia.org/wiki/Division_by_zero#Computer_arithmetic
Upvotes: 3