Java - float type special values

What are the float type special values?

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 ConstantsMeaning
Float.POSITIVE_INFINITYPositive infinity of type float
Float.NEGATIVE_INFINITYNegative infinity of type float
Float.NaN Not a Number of type float
Float.MAX_VALUEThe largest positive value that can be represented in a float variable. This is equal to 3.4 x 10^38 approx.
Float.MIN_VALUEThe smallest positive value greater than zero that can be represented in a float variable. This is equal to 1.4 x 10^-45.

Demo

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);/*from w  ww.ja v  a 2  s  . c  o  m*/
    System.out.println(f2);
    System.out.println(f3);
    System.out.println(f4);
    System.out.println(f5);
  }
}

Result