When does java print infinity and when does it print NaN?
Why is 1.0 / 0.0 infinity, but ((1.0 / 0.0) - (1.0 / 0.0)) NaN and 0.0f / 0.0f NaN?
What is the difference between the two?
Because Java follows the well-known mathematical facts. 1.0 / 0.0 infinity , and the rest are indefinite forms , which Java represents as NaN(and not a number).
NaN
1.00 / 0 goes on forever, but infinity minus infinity is not a number.
Java, IEEE 754, .