Predefined value for float type
In this chapter you will learn:
Maximum value and Minimum value a float type
Float class defines the following constants:
static float MAX_VALUE
stores largest positive finite value of type float.static float MIN_VALUE
stores smallest positive nonzero value of type float.static int MAX_EXPONENT
stores maximum exponent a finite float variable may have.static int MIN_EXPONENT
stores minimum exponent a normalized float variable may have.static float MIN_NORMAL
stores smallest positive normal value of type float.
The following code prints out the constants listed above.
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);
}/* jav a 2s . c o m*/
}
The output:
The following lists more of the constants:
static float NaN
stores Not-a-Number (NaN) value of type float.static float NEGATIVE_INFINITY
stores negative infinity of type float.static float POSITIVE_INFINITY
stores positive infinity of type float.static int SIZE
stores the number of bits used to represent a float value.
The following code prints out the constants listed above.
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);
}//from j a va2s . c o m
}
The output:
Next chapter...
What you will learn in the next chapter:
Home » Java Tutorial » Primitive Data Types