Android
java.lang
public final class

java.lang.Double

java.lang.Object
java.lang.Number Serializable
java.lang.Double Comparable<T>

Double is the wrapper for the primitive type double.

See Also

Summary

Constants

      Value  
double  MAX_VALUE 

Constant for the maximum double value, (2 - 2-52/sup>) * 21023

1.7976931348623157E308 
double  MIN_VALUE 

Constant for the minimum double value, 2-1074

4.9E-324 
double  NEGATIVE_INFINITY 

Constant for the Negative Infinity value of the double type. 

-Infinity 
double  NaN 

Constant for the Not-a-Number (NaN) value of the double type. 

NaN 
double  POSITIVE_INFINITY 

Constant for the Positive Infinity value of the double type. 

Infinity 
int  SIZE 

Constant for the number of bits to represent a double in two's compliment form. 

64  0x00000040 
Class<Double TYPE  The java.lang.Class that represents this class.     

Public Constructors

            Double(double value)
Constructs a new instance of the receiver which represents the double valued argument.
            Double(String string)
Constructs a new instance of this class given a string.

Public Methods

          byte  byteValue()
Returns the byte value which the receiver represents
      static    int  compare(double double1, double double2)
Compares the two doubles.
          int  compareTo(Double object)
Compares the receiver with the Double parameter.
      static    long  doubleToLongBits(double value)
Returns the binary representation of the argument, as a long.
      static    long  doubleToRawLongBits(double value)
Returns the binary representation of the argument, as a long.
          double  doubleValue()
Returns the receiver's value as a double.
          boolean  equals(Object object)
Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.
          float  floatValue()
Returns the float value which the receiver represents
          int  hashCode()
Returns an integer hash code for the receiver.
          int  intValue()
Returns the receiver's value as an integer.
      static    boolean  isInfinite(double d)
Returns true if the argument represents an infinite quantity, and false otherwise.
          boolean  isInfinite()
Returns true if the receiver represents an infinite quantity, and false otherwise.
      static    boolean  isNaN(double d)
Returns true if the argument does not represent a valid double quantity.
          boolean  isNaN()
Returns true if the receiver does not represent a valid float quantity.
      static    double  longBitsToDouble(long bits)
Returns a double built from the binary representation given in the argument.
          long  longValue()
Returns the long value which the receiver represents
      static    double  parseDouble(String string)
Returns the double which matches the passed in string.
          short  shortValue()
Returns the short value which the receiver represents
      static    String  toHexString(double d)

Converts a double into a hexadecimal string representation.

          String  toString()
Returns a string containing a concise, human-readable description of the receiver.
      static    String  toString(double d)
Returns a string containing a printable representation of the argument.
      static    Double  valueOf(String string)
Returns the double which matches the passed in string.
      static    Double  valueOf(double d)

Returns a Double instance for the double value passed.

Methods inherited from class java.lang.Number
Methods inherited from class java.lang.Object
Methods inherited from interface java.lang.Comparable

Details

Constants

public static final double MAX_VALUE

Constant for the maximum double value, (2 - 2-52/sup>) * 21023.

Constant Value: 1.7976931348623157E308

public static final double MIN_VALUE

Constant for the minimum double value, 2-1074.

Constant Value: 4.9E-324

public static final double NEGATIVE_INFINITY

Constant for the Negative Infinity value of the double type.

Constant Value: -Infinity

public static final double NaN

Constant for the Not-a-Number (NaN) value of the double type.

Constant Value: NaN

public static final double POSITIVE_INFINITY

Constant for the Positive Infinity value of the double type.

Constant Value: Infinity

public static final int SIZE

Constant for the number of bits to represent a double in two's compliment form.

Constant Value: 64 (0x00000040)

public static final Class<Double> TYPE

The java.lang.Class that represents this class.

Public Constructors

public Double(double value)

Constructs a new instance of the receiver which represents the double valued argument.

Parameters

value the double to store in the new instance.

public Double(String string)

Constructs a new instance of this class given a string.

Parameters

string a string representation of a double quantity.

Throws

NumberFormatException if the argument could not be parsed as a double quantity.

Public Methods

public byte byteValue()

Returns the byte value which the receiver represents

Returns

  • byte the value of the receiver.

public static int compare(double double1, double double2)

Compares the two doubles. NaN is equal to NaN, and is greater than other double values. 0d is greater than -0d.

Parameters

double1 the first value to compare
double2 the second value to compare

Returns

  • Returns greater than zero when double1 is greater than double2, zero when double1 equals double2, and less than zero when double1 is less than double2

public int compareTo(Double object)

Compares the receiver with the Double parameter. NaN is equal to NaN, and is greater than other double values. 0d is greater than -0d.

Parameters

object the Double to compare to the receiver

Returns

  • Returns greater than zero when this.doubleValue() is greater than object.doubleValue(), zero when this.doubleValue() equals object.doubleValue(), and less than zero when this.doubleValue() is less than object.doubleValue()

Throws

NullPointerException if object is null.

public static long doubleToLongBits(double value)

Returns the binary representation of the argument, as a long.

Parameters

value The double value to convert

Returns

  • the bits of the double.

public static long doubleToRawLongBits(double value)

Returns the binary representation of the argument, as a long.

Parameters

value The double value to convert

Returns

  • the bits of the double.

public double doubleValue()

Returns the receiver's value as a double.

Returns

  • the receiver's value

public boolean equals(Object object)

Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison. For Doubles, the check verifies that the receiver's value's bit pattern matches the bit pattern of the argument, which must also be a Double.

Parameters

object the object to compare with this object

Returns

  • true if the object is the same as this object false if it is different from this object

See Also

public float floatValue()

Returns the float value which the receiver represents

Returns

  • float the value of the receiver.

public int hashCode()

Returns an integer hash code for the receiver. Any two objects which answer true when passed to equals must answer the same value for this method.

Returns

  • the receiver's hash

See Also

public int intValue()

Returns the receiver's value as an integer.

Returns

  • the receiver's value as an integer

public static boolean isInfinite(double d)

Returns true if the argument represents an infinite quantity, and false otherwise.

Parameters

d value to check for infinitness.

Returns

  • true if the argument is positive or negative infinity false if it is not an infinite value

public boolean isInfinite()

Returns true if the receiver represents an infinite quantity, and false otherwise.

Returns

  • true if the argument is positive or negative infinity false if it is not an infinite value

public static boolean isNaN(double d)

Returns true if the argument does not represent a valid double quantity.

Parameters

d value to check for numberness.

Returns

  • true if the argument is Not A Number false if it is a (potentially infinite) double number

public boolean isNaN()

Returns true if the receiver does not represent a valid float quantity.

Returns

  • true if the argument is Not A Number false if it is a (potentially infinite) float number

public static double longBitsToDouble(long bits)

Returns a double built from the binary representation given in the argument.

Parameters

bits the bits of the double

Returns

  • the double which matches the bits

public long longValue()

Returns the long value which the receiver represents

Returns

  • long the value of the receiver.

public static double parseDouble(String string)

Returns the double which matches the passed in string. NumberFormatException is thrown if the string does not represent a valid double.

Parameters

string the value to convert

Returns

  • a double which would print as the argument

public short shortValue()

Returns the short value which the receiver represents

Returns

  • short the value of the receiver.

public static String toHexString(double d)

Converts a double into a hexadecimal string representation.

Parameters

d The double to convert.

Returns

  • The hexadecimal string representation of f.

public String toString()

Returns a string containing a concise, human-readable description of the receiver.

Returns

  • a printable representation for the receiver.

public static String toString(double d)

Returns a string containing a printable representation of the argument.

Parameters

d the double to print

Returns

  • a printable representation of the argument.

public static Double valueOf(String string)

Returns the double which matches the passed in string. NumberFormatException is thrown if the string does not represent a valid double.

Parameters

string the value to convert

Returns

  • a double which would print as the argument

public static Double valueOf(double d)

Returns a Double instance for the double value passed. This method is preferred over the constructor, as this method may maintain a cache of instances.

Parameters

d The double value.

Returns

  • A Double instance.
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:56