aicas logoJamaica 3.2 release 62

java.lang
Class Double

java.lang.Object
  extended by java.lang.Number
      extended by java.lang.Double
All Implemented Interfaces:
Serializable, Comparable<Double>

public final class Double
extends Number
implements Comparable<Double>

Double provides a class for double values stored in objects.

See Also:
Serialized Form

Field Summary
static int MAX_EXPONENT
          The maximum value the exponent may have.
static double MAX_VALUE
          The largest value a double can hold.
static int MIN_EXPONENT
          The minimum value the exponent may have.
static double MIN_NORMAL
          The smallest positive value that can be represented by a normalized double.
static double MIN_VALUE
          The smallest value a double can hold.
static double NaN
          Numerical constant: NaN
static double NEGATIVE_INFINITY
          Numerical constant: -Infinity
static double POSITIVE_INFINITY
          Numerical constant: +Infinity
static int SIZE
          The size occupied by one double in bits.
static Class<Double> TYPE
          type for double.
 
Constructor Summary
Double(double value)
          Constructor to create an instance of Double with the given double value.
Double(String s)
          Constructor to create an instance of Double with the value provided as a string.
 
Method Summary
 byte byteValue()
          byteValue returns the value of this as a byte.
static int compare(double v1, double v2)
          compare compares two double values
 int compareTo(Double anotherDouble)
          compareTo compares this to another Double value.
static long doubleToLongBits(double value)
          doubleToLongBits returns the integer representation of a double value.
static long doubleToRawLongBits(double value)
          doubleToRawLongBits returns the raw integer representation of a double value.
 double doubleValue()
          doubleValue returns the value of this as a double.
 boolean equals(Object obj)
          equals tests if 2 double instances are equal.
 float floatValue()
          floatValue returns the value of this as a float.
 int hashCode()
          hashCode determines a hashCode for this Double instance.
 int intValue()
          intValue returns the value of this as an int.
 boolean isInfinite()
          isInfinite checks if this instance represents Infinity or -Infinity.
static boolean isInfinite(double v)
          isInfinite checks if the double value is Infinity or -Infinity.
 boolean isNaN()
          isNaN checks if this instance represents a NaN
static boolean isNaN(double v)
          isNaN checks if the double value is a NaN.
static double longBitsToDouble(long bits)
          longBitsToDouble creates a double value with the given integer representation.
 long longValue()
          longValue returns the value of this as a long.
static double parseDouble(String doubleString)
          parseDouble parses a double value given as a string.
 short shortValue()
          shortValue returns the value of this as a short.
static String toHexString(double d)
          Convert this double value to a hex string of the form "0x0.123456p123".
 String toString()
          toString converts the value of this instance to a string just as toString(doubleValue()).
static String toString(double v)
          toString converts a given double value to a string.
static Double valueOf(double d)
          valueOf returns a Double instance with the given value.
static Double valueOf(String s)
          valueOf creates an instance of Double with the value provided as a 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
Numerical constant: +Infinity

See Also:
Constant Field Values

NEGATIVE_INFINITY

public static final double NEGATIVE_INFINITY
Numerical constant: -Infinity

See Also:
Constant Field Values

NaN

public static final double NaN
Numerical constant: NaN

See Also:
Constant Field Values

MIN_VALUE

public static final double MIN_VALUE
The smallest value a double can hold.

See Also:
Constant Field Values

MAX_VALUE

public static final double MAX_VALUE
The largest value a double can hold.

See Also:
Constant Field Values

MIN_NORMAL

public static final double MIN_NORMAL
The smallest positive value that can be represented by a normalized double.

Since:
1.6
See Also:
Constant Field Values

MAX_EXPONENT

public static final int MAX_EXPONENT
The maximum value the exponent may have. NYI: 1.6 field: Check if value is correct.

Since:
1.6
See Also:
Constant Field Values

MIN_EXPONENT

public static final int MIN_EXPONENT
The minimum value the exponent may have. NYI: 1.6 field: Check if value is correct.

Since:
1.6
See Also:
Constant Field Values

SIZE

public static final int SIZE
The size occupied by one double in bits.

Since:
1.5
See Also:
Constant Field Values

TYPE

public static final Class<Double> TYPE
type for double.

Since:
1.1
Constructor Detail

Double

public Double(double value)
Constructor to create an instance of Double with the given double value.

Parameters:
value - the value for this instance.

Double

public Double(String s)
       throws NumberFormatException
Constructor to create an instance of Double with the value provided as a string.

Parameters:
s - the string representation of the value.
Throws:
NumberFormatException - if s could not be parsed as a double.
Method Detail

toString

public static String toString(double v)
toString converts a given double value to a string. Converts special values NaN, positive and negative Infinitiy to "NaN", "Infinity" and "-Infinity", respectively. All other values are represented in the form "#.###[E[-]##]".

Parameters:
v - the double value.
Returns:
the string representing the same value.

toHexString

public static String toHexString(double d)
Convert this double value to a hex string of the form "0x0.123456p123".

Parameters:
d - a double
Returns:
the hex string
Since:
1.5

valueOf

public static Double valueOf(String s)
                      throws NumberFormatException
valueOf creates an instance of Double with the value provided as a string.

Parameters:
s - the string representation of the value.
Returns:
an instance of Double that represents the given value.
Throws:
NumberFormatException - if s could not be parsed as a double.

valueOf

public static Double valueOf(double d)
valueOf returns a Double instance with the given value. A cache is used to speed up multiple allocations of the same Double instance.

Parameters:
d - the double value
Returns:
an instance with value equal to d.
Since:
1.5

parseDouble

public static double parseDouble(String doubleString)
parseDouble parses a double value given as a string. The value may be of the form "[+|-]#{#}[.#{#}[E[+|-]#{#}]][D|F]".

Parameters:
doubleString - the string represenation.
Returns:
the corresponding double value or +/-Infinity in case of an
         overflow.
 
Since:
1.2

isNaN

public static boolean isNaN(double v)
isNaN checks if the double value is a NaN.

Parameters:
v - the double value.
Returns:
true iff v is NaN

isInfinite

public static boolean isInfinite(double v)
isInfinite checks if the double value is Infinity or -Infinity.

Parameters:
v - the double value
Returns:
true iff v is Infinity of -Infinity.

isNaN

public boolean isNaN()
isNaN checks if this instance represents a NaN

Returns:
true iff this is NaN

isInfinite

public boolean isInfinite()
isInfinite checks if this instance represents Infinity or -Infinity.

Returns:
true iff this is Infinity of -Infinity.

toString

public String toString()
toString converts the value of this instance to a string just as toString(doubleValue()).

Overrides:
toString in class Object
Returns:
the string representing the same value as this.

byteValue

public byte byteValue()
byteValue returns the value of this as a byte.

Overrides:
byteValue in class Number
Returns:
the value converted to byte.
Since:
1.1

shortValue

public short shortValue()
shortValue returns the value of this as a short.

Overrides:
shortValue in class Number
Returns:
the value converted to short.
Since:
1.1

intValue

public int intValue()
intValue returns the value of this as an int.

Specified by:
intValue in class Number
Returns:
the value converted to int.

longValue

public long longValue()
longValue returns the value of this as a long.

Specified by:
longValue in class Number
Returns:
the value converted to long.

floatValue

public float floatValue()
floatValue returns the value of this as a float.

Specified by:
floatValue in class Number
Returns:
the value converted to float.

doubleValue

public double doubleValue()
doubleValue returns the value of this as a double.

Specified by:
doubleValue in class Number
Returns:
the value converted to double.

hashCode

public int hashCode()
hashCode determines a hashCode for this Double instance.

Overrides:
hashCode in class Object
Returns:
the hash code.

equals

public boolean equals(Object obj)
equals tests if 2 double instances are equal. Two instances are equal if their bit patterns (see doubleToLongBits) are equal, i.e., this function does not returns the same value as a plain comparison "d1==d2" would.

Overrides:
equals in class Object
Parameters:
obj - the other double value
Returns:
true iff obj is an isntance of Double and doubleToLongBits(value) ==
         doubleToLongBits(((Double) obj).doubleValue()).
 

doubleToLongBits

public static long doubleToLongBits(double value)
doubleToLongBits returns the integer representation of a double value.

Parameters:
value - the double value.
Returns:
the bits of the double value interpreted as a long.

doubleToRawLongBits

public static long doubleToRawLongBits(double value)
doubleToRawLongBits returns the raw integer representation of a double value. The raw representation permits several integer representations for the same values: NaN and +/-Infinity.

Parameters:
value - the double value.
Returns:
the bits of the double value interpreted as a long.

longBitsToDouble

public static double longBitsToDouble(long bits)
longBitsToDouble creates a double value with the given integer representation.

Parameters:
bits - the integer representation.
Returns:
the double value.

compareTo

public int compareTo(Double anotherDouble)
compareTo compares this to another Double value.

Specified by:
compareTo in interface Comparable<Double>
Parameters:
anotherDouble - the other double
Returns:
-1 if this is smaller than, 0 if this is equal to, +1 if this is
         larger than o.
 
Since:
1.2

compare

public static int compare(double v1,
                          double v2)
compare compares two double values

Parameters:
v1 - the first double value
v2 - the second double value
Returns:
-1 if this is smaller than, 0 if this is equal to, +1 if this is larger than o.
Since:
1.4

aicas logoJamaica 3.2 release 62

aicas GmbH, Karlsruhe - Germany    www.aicas.com
Copyright 2001-2008 aicas GmbH. All Rights Reserved.