The float data type defines two infinities: positive infinity and negative infinity.
The result of the dividing 3.25F by 0.0F is a float positive infinity.
The result of the dividing 3.25F by -0.0F is a float negative infinity.
Dividing 0.0F by 0.0F is indeterminate.
Indeterminate results are represented the float data type called NaN (Not-a-Number).
Java has a Float class which defines five constants that represent positive infinity, negative infinity, and NaN of the float data type.
float Constants | Meaning |
---|---|
Float.POSITIVE_INFINITY | Positive infinity of type float |
Float.NEGATIVE_INFINITY | Negative infinity of type float |
Float.NaN | Not a Number of type float |
Float.MAX_VALUE | The largest positive value that can be represented in a float variable. This is equal to 3.4 x 10^38 approx. |
Float.MIN_VALUE | The smallest positive value greater than zero that can be represented in a float variable. This is equal to 1.4 x 10^-45. |
public class Main { public static void main(String[] args) { float f1 = Float.POSITIVE_INFINITY; float f2 = Float.NEGATIVE_INFINITY; float f3 = Float.NaN ; float f4 = Float.MAX_VALUE; float f5 = Float.MIN_VALUE; System.out.println(f1);// ww w. j a v a2 s . c o m System.out.println(f2); System.out.println(f3); System.out.println(f4); System.out.println(f5); } }