SunSPOT API V3.0


java.lang
Class Double

java.lang.Object
  extended by java.lang.Double

public final class Double
extends Object

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.

Version:
1.34, 02 May 1996
Author:
Lee Boynton, Arthur van Hoff

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.
 
Method Summary
 byte byteValue()
          Returns the value of this Double as a byte (by casting to a byte).
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).
static double parseDouble(String s)
          Returns a new double initialized to the value represented by the specified String, as performed by the valueOf method of class Double.
 short shortValue()
          Returns the value of this Double as a short (by casting to a short).
 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
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

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 equal to the value of longBitsToDouble(1L)

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

POSITIVE_INFINITY

public static final double POSITIVE_INFINITY
Positive infinity.

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
Method Detail

byteValue

public byte byteValue()
Returns the value of this Double as a byte (by casting to a byte).


doubleToLongBits

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


doubleValue

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


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:
Boolean.hashCode(), Hashtable

floatValue

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


hashCode

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

Overrides:
hashCode in class Object
Returns:
a hash code value for this object.
See Also:
Object.equals(java.lang.Object), Hashtable

intValue

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


isInfinite

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


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.


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

longBitsToDouble

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


longValue

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


parseDouble

public static double parseDouble(String s)
                          throws NumberFormatException
Returns a new double initialized to the value represented by the specified String, as performed by the valueOf method of class Double.

Parameters:
s - the string to be parsed.
Returns:
the double value represented by the string argument.
Throws:
NumberFormatException - if the string does not contain a parsable double.
Since:
JDK1.2
See Also:
valueOf(String)

shortValue

public short shortValue()
Returns the value of this Double as a short (by casting to a short).


toString

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

Overrides:
toString in class Object
Returns:
a string representation of the object.

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.

SunSPOT API V3.0


Copyright © 2006, 2007 Sun Microsystems, Inc. All Rights Reserved.