Type | Field | Summary |
---|---|---|
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. |
static Class | TYPE | The Class instance representing the primitive type double. |
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
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);
}
}
}
d = -Infinity
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. |