anything special with double data type?
Yes, double
can represent infinity (as can float
), whereas int
can't. The floating point types follow IEEE 754, which allows for signed infinity values, as well as "not a number" (NaN) values, such as trying to obtain the square root of -1.
From JLS 15.17.2 (division):
if the value of the divisor in an integer division is 0, then an ArithmeticException is thrown.
and
The result of a floating-point division is determined by the rules of IEEE 754 arithmetic:
- ...
- Division of a zero by a zero results in NaN; division of zero by any other finite value results in a signed zero. The sign is determined by the rule stated above.
- Division of a nonzero finite value by a zero results in a signed infinity.