How can we use them in our codes, and what will cause NaN(not a number)?
0/0
.And the constants from the specification of the Float
class:
More information can be found in the IEEE-754 page in Wikipedia.
Here's a little program to illustrate the three constants:
System.out.println(0f / 0f);
System.out.println(1f / 0f);
System.out.println(-1f / 0f);
Output:
NaN
Infinity
-Infinity