Constants in Double class
static int MAX_EXPONENT
- Maximum exponent a finite double variable may have.
static double MAX_VALUE
- Largest positive finite value of type double.
static int MIN_EXPONENT
- Minimum exponent a normalized double variable may have.
static double MIN_NORMAL
- Smallest positive normal value of type double.
static double MIN_VALUE
- Smallest positive nonzero value of type double.
static double NaN
- Not-a-Number (NaN) value of type double.
static double NEGATIVE_INFINITY
- Negative infinity of type double.
static double POSITIVE_INFINITY
- Positive infinity of type double.
static int SIZE
- The number of bits used to represent a double value.
The following code finds out the min/max value a double type variable can have. It also prints out the size of a double value.
public class Main {
public static void main(String[] args) {
System.out.println(Double.MAX_VALUE);
System.out.println(Double.MIN_VALUE);
System.out.println(Double.SIZE);
}
}
The output:
1.7976931348623157E308
4.9E-324
64
public class Main {
public static void main(String[] args) {
System.out.println(Double.MAX_EXPONENT);
System.out.println(Double.MIN_EXPONENT);
System.out.println(Double.MIN_NORMAL);
}
}
The output:
1023
-1022
2.2250738585072014E-308
The following code uses the
Double.NEGATIVE_INFINITY
to check a double value.
public class Main {
public static void main(String args[]) {
double d = -10.0 / 0.0;
if (d == Double.NEGATIVE_INFINITY) {
System.out.println("d = " + d);
}
}
}
The output:
d = -Infinity
Home
Java Book
Essential Classes
Java Book
Essential Classes
Double:
- Double class
- Constants in Double class
- Double class Constructor
- Return double value as byte, double, float, int, long, short
- Compare two double values
- Is a double value an infinite large value, or it is not a number.
- Convert string value to double
- Convert double value from string
- Get the hexadecimal string representation
- Bit oriented calculation for double type