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  

Double:
  1. Double class
  2. Constants in Double class
  3. Double class Constructor
  4. Return double value as byte, double, float, int, long, short
  5. Compare two double values
  6. Is a double value an infinite large value, or it is not a number.
  7. Convert string value to double
  8. Convert double value from string
  9. Get the hexadecimal string representation
  10. Bit oriented calculation for double type