Why does java return positive infinity when it exceeds Double.Max_Value?
1 answer
From the Java Language Specification
The result of a floating point multiplication is determined by the rules of IEEE 754 arithmetic:
- [...]
- If the quantity of the product is too large to represent, we say that the operation is overflowed ; the result is the infinity of the corresponding sign .
Since it is Double.MAX_VALUE * Double.MAX_VALUE
too large to represent, its meaning becomes infinite.
+6
source to share