java.lang
Class Double

java.lang.Object
  |
  +--java.lang.Number
        |
        +--java.lang.Double

public final class Double
extends Number

The Double class provides an object wrapper for Double data values and serves as a place for double-oriented operations. A wrapper is useful because most of Java's utility classes require the use of objects. Since doubles are not objects in Java, they need to be "wrapped" in a Double instance.


Field Summary
static double MAX_VALUE
          The maximum value a double can have.
static double MIN_VALUE
          The minimum value a double can have.
static double NaN
          Not-a-Number.
static double NEGATIVE_INFINITY
          Negative infinity.
static double POSITIVE_INFINITY
          Positive infinity.
 
Constructor Summary
Double(double value)
          Constructs a Double wrapper for the specified double value.
Double(String s)
          Constructs a Double object initialized to the value specified by the String parameter.
 
Method Summary
static long doubleToLongBits(double value)
          Returns the bit represention of a double-float value
 double doubleValue()
          Returns the double value of this Double.
 boolean equals(Object obj)
          Compares this object against the specified object.
 float floatValue()
          Returns the float value of this Double.
 int hashCode()
          Returns a hashcode for this Double.
 int intValue()
          Returns the integer value of this Double (by casting to an int).
 boolean isInfinite()
          Returns true if this Double value is infinitely large in magnitude.
static boolean isInfinite(double v)
          Returns true if the specified number is infinitely large in magnitude.
 boolean isNaN()
          Returns true if this Double value is the special Not-a-Number (NaN) value.
static boolean isNaN(double v)
          Returns true if the specified number is the special Not-a-Number (NaN) value.
static double longBitsToDouble(long bits)
          Returns the double-float corresponding to a given bit represention.
 long longValue()
          Returns the long value of this Double (by casting to a long).
 String toString()
          Returns a String representation of this Double object.
static String toString(double d)
          Returns a String representation for the specified double value.
static Double valueOf(String s)
          Returns a new Double value initialized to the value represented by the specified String.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

POSITIVE_INFINITY

public static final double POSITIVE_INFINITY
Positive infinity.

See Also:
Constant Field Values

NEGATIVE_INFINITY

public static final double NEGATIVE_INFINITY
Negative infinity.

See Also:
Constant Field Values

NaN

public static final double NaN
Not-a-Number. Is not equal to anything, including itself.

See Also:
Constant Field Values

MAX_VALUE

public static final double MAX_VALUE
The maximum value a double can have. The greatest maximum value that a double can have is 1.79769313486231570e+308d.

See Also:
Constant Field Values

MIN_VALUE

public static final double MIN_VALUE
The minimum value a double can have. The lowest minimum value that a double can have is 2.2250738585072014E-308.

See Also:
Constant Field Values
Constructor Detail

Double

public Double(double value)
Constructs a Double wrapper for the specified double value.

Parameters:
value - the initial value of the double

Double

public Double(String s)
       throws NumberFormatException
Constructs a Double object initialized to the value specified by the String parameter.

Parameters:
s - the String to be converted to a Double
Throws:
NumberFormatException - If the String does not contain a parsable number.
Method Detail

toString

public static String toString(double d)
Returns a String representation for the specified double value.

Parameters:
d - the double to be converted

valueOf

public static Double valueOf(String s)
                      throws NumberFormatException
Returns a new Double value initialized to the value represented by the specified String.

Parameters:
s - the String to be parsed
Throws:
NumberFormatException - If the String cannot be parsed.

isNaN

public static boolean isNaN(double v)
Returns true if the specified number is the special Not-a-Number (NaN) value.

Parameters:
v - the value to be tested

isInfinite

public static boolean isInfinite(double v)
Returns true if the specified number is infinitely large in magnitude.

Parameters:
v - the value to be tested

isNaN

public boolean isNaN()
Returns true if this Double value is the special Not-a-Number (NaN) value.


isInfinite

public boolean isInfinite()
Returns true if this Double value is infinitely large in magnitude.


toString

public String toString()
Returns a String representation of this Double object.

Overrides:
toString in class Object

intValue

public int intValue()
Returns the integer value of this Double (by casting to an int).

Specified by:
intValue in class Number

longValue

public long longValue()
Returns the long value of this Double (by casting to a long).

Specified by:
longValue in class Number

floatValue

public float floatValue()
Returns the float value of this Double.

Specified by:
floatValue in class Number

doubleValue

public double doubleValue()
Returns the double value of this Double.

Specified by:
doubleValue in class Number

hashCode

public int hashCode()
Returns a hashcode for this Double.

Overrides:
hashCode in class Object
See Also:
Hashtable

equals

public boolean equals(Object obj)
Compares this object against the specified object. To be useful in hashtables this method considers two NaN double values to be equal. This is not according to IEEE specification.

Overrides:
equals in class Object
Parameters:
obj - the object to compare with
Returns:
true if the objects are the same; false otherwise.
See Also:
Hashtable

doubleToLongBits

public static long doubleToLongBits(double value)
Returns the bit represention of a double-float value


longBitsToDouble

public static double longBitsToDouble(long bits)
Returns the double-float corresponding to a given bit represention.