Find out the Maximum value and Minimum value a float type can have

TypeFieldSummary
static floatMAX_VALUELargest positive finite value of type float.
static floatMIN_VALUESmallest positive nonzero value of type float.
static intMAX_EXPONENTMaximum exponent a finite float variable may have.
static intMIN_EXPONENTMinimum exponent a normalized float variable may have.
static floatMIN_NORMALSmallest positive normal value of type float.

public class Main {
  public static void main(String[] args) {
    System.out.println("MAX_VALUE:"+Float.MAX_VALUE);
    System.out.println("MIN_VALUE:"+Float.MIN_VALUE);
    System.out.println("MAX_EXPONENT:"+Float.MAX_EXPONENT);
    System.out.println("MIN_EXPONENT:"+Float.MIN_EXPONENT);
    System.out.println("MIN_NORMAL:"+Float.MIN_NORMAL);
  }
}

The output:


MAX_VALUE:3.4028235E38
MIN_VALUE:1.4E-45
MAX_EXPONENT:127
MIN_EXPONENT:-126
MIN_NORMAL:1.17549435E-38

TypeFieldSummary
static floatNaNNot-a-Number (NaN) value of type float.
static floatNEGATIVE_INFINITYNegative infinity of type float.
static floatPOSITIVE_INFINITYPositive infinity of type float.
static intSIZEThe number of bits used to represent a float value.
static ClassTYPEThe Class instance representing the primitive type float.

public class Main {
  public static void main(String[] args) {
    System.out.println("NaN:"+Float.NaN);
    System.out.println("NEGATIVE_INFINITY:"+Float.NEGATIVE_INFINITY);
    System.out.println("POSITIVE_INFINITY:"+Float.POSITIVE_INFINITY);
    System.out.println("SIZE:"+Float.SIZE);
  }
}

The output:


NaN:NaN
NEGATIVE_INFINITY:-Infinity
POSITIVE_INFINITY:Infinity
SIZE:32
java2s.com  |  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.