Double

Name

Double

Synopsis

Description

The Double class provides an object wrapper for a double value. This is useful when you need to treat a double value as an object. For example, there are a number of utility methods that take a reference to an Object as one of their arguments. You cannot specify a double value for one of these arguments, but you can provide a reference to a Double object that encapsulates the double value. Furthermore, as of JDK 1.1, the Double class is necessary to support the Reflection API and class literals.

In Java, double values are represented using the IEEE 754 format. The Double class provides constants for the three special values that are mandated by this format: POSITIVE_INFINITY, NEGATIVE_INFINITY, and NaN (not-a-number).

The Double class also provides some utility methods, such as methods for determining whether a double value is an infinity value or NaN, for converting double values to other primitive types, and for converting a double to a String and vice versa.

Class Summary

public final class java.lang.Double extends java.lang.Number {
 // Constants public final static double MAX_VALUE;
public final static double MIN_VALUE;
public final static double NaN;
public final static double NEGATIVE_INFINITY;
public final static double POSITIVE_INFINITY;
public final static Class TYPE; // New in 1.1 // Constructors public Double(double value);
public Double(String s); // Class Methods public static native long doubleToLongBits(double value);
public static boolean isInfinite(double v);
public static boolean isNaN(double v);
public static native double longBitsToDouble(long bits);
public static String toString(double d);
public static Double valueOf(String s); // Instance Methods public byte byteValue(); // New in 1.1 public double doubleValue();
public boolean equals(Object obj);
public float floatValue();
public int hashCode();
public int intValue();
public boolean isInfinite();
public boolean isNaN();
public long longValue();
public short shortValue(); // New in 1.1 public String toString();
}

Constants

MAX_VALUE

public static final double MAX_VALUE = 1.79769313486231570e+308 

MIN_VALUE

public static final double MIN_VALUE = 4.94065645841246544e-324 

NaN

public static final double NaN = 0.0 / 0.0

NEGATIVE_INFINITY

public static final double NEGATIVE_INFINITY = -1.0 / 0.0

POSITIVE_INFINITY

public static final double POSITIVE_INFINITY = 1.0 / 0.0

TYPE

public static final Class TYPE

Constructors

Double

public Double(double value)

public Double(String s) throws NumberFormatException

Class Methods

doubleToLongBits

public static native long doubleToLongBits(double value)

isInfinite

static public boolean isInfinite(double v)

isNaN

public static boolean isNaN(double v)

longBitsToDouble

public static native double longBitsToDouble(long bits)

toString

public static String toString(double d)

valueOf

public static Double valueOf(String s) throws NumberFormatException 

Instance Methods

byteValue

public byte byteValue()

doubleValue

public double doubleValue()

equals

public boolean equals(Object obj)

floatValue

public float floatValue()

hashCode

public int hashCode()

intValue

public int intValue()

isInfinite

public boolean isInfinite()

isNaN

public boolean isNaN()

longValue

public long longValue()

shortValue

public short shortValue()

toString

public String toString()

Inherited Methods

Method Inherited From Method Inherited From
clone() Object finalize() Object
getClass() Object notify() Object
notifyAll() Object wait() Object
wait(long) Object wait(long, int) Object

See Also

Class; Exceptions; Float; Floating-point literals; Floating-point types; Number; String