Package java.lang |
![]() Previous |
![]() Java API |
![]() Index |
![]() Next |
public final class java.lang.Double extends java.lang.Number { // Fields 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; // Constructors public Double(double value); public Double(String s); // Methods public static long doubleToLongBits(double value); public double doubleValue(); public boolean equals(Object obj); public float floatValue(); public int hashCode(); public int intValue(); public boolean isInfinite(); public static boolean isInfinite(double v); public boolean isNaN(); public static boolean isNaN(double v); public static double longBitsToDouble(long bits); public long longValue(); public String toString(); public static String toString(double d); public static Double valueOf(String s); }
This class wraps a value of the primitive type double in an object. An object of type Double contains a single field whose type is double.
In addition, this class provides a number of methods for converting a double to a String and a String to a double, as well as other constants and methods useful when dealing with a double.
public final static doubleMAX_VALUE = 1.79769313486231570e+308dThe largest positive value of type double.
public final static doubleMIN_VALUE = 4.94065645841246544e-324The smallest positive finite value of type double.
public final static double NaN = 0.0 / 0.0A Not-a-Number value of type double.
public final static doubleNEGATIVE_INFINITY = -1.0 / 0.0The negative infinity of type double.
public final static doublePOSITIVE_INFINITY = 1.0 / 0.0The positive infinity of type double.
public Double(double value)Constructs a newly allocated Double object that represents the primitive double argument.
Parameter Description value the value to be represented by the Double
public Double(String s)throws NumberFormatExceptionConstructs a newly allocated Double object that represents the floating- point value of type double represented by the string. The string is converted to a double value as if by the valueOf method .
Parameter Description s a string to be converted to a Double Throw:
If the string does not contain a parsable number.
public static long doubleToLongBits(double value)The result is a representation of the floating-point argument according to the IEEE 754 floating-point "double format" bit layout.
Bit 63 represents the sign of the floating-point number. Bits 62-52 represent the exponent. Bits 51-0 represent the significand (sometimes called the mantissa) of the floating-point number.
If the argument is positive infinity, the result is 0x7ff0000000000000L.
If the argument is negative infinity, the result is 0xfff0000000000000L.
If the argument is NaN, the result is 0x7ff8000000000000L.
Return Value:
Returns the bits that represent the floating point number.
Parameter Description value a double precision floating point number
public double doubleValue()Return Value:
Returns the double value represented by this object.
Overrides:
doubleValue in class Number .
public boolean equals(Object obj)The result is true if and only if the argument is not null and is a Double object that represents a double that has the identical bit pattern to the bit pattern of the double represented by this object.
Note that in most cases, for two instances of class Double, d1 and d2, the value of d1.equals(d2) is true if and only if d1.doubleValue() == d2.longValue() also has the value true. However, there are two exceptions:
- If d1 and d2 both represent Double.NaN,then the equals method returns true, even though Double.NaN==Double.NaN has the value false.
- If d1 represents +0.0 while d2 represents -0.0, or vice versa, the equal test has the value false, even though +0.0==-0.0 has the value true.
Return Value:
Returns true if the objects are the same; false otherwise.
Parameter Description obj the object to compare with Overrides:
equals in class Object .
public float floatValue()Returns the double value represented by this object is converted to type float and the result of the conversion is returned.
Overrides:
floatValue in class Number .
public int hashCode()Return Value:
Returns a hash code value for this object.
Overrides:
hashCode in class Object .
public int intValue()Returns the double value represented by this object is converted to type int and the result of the conversion is returned.
Overrides:
intValue in class Number .
public boolean isInfinite()Returns true if the value represented by this object is positive infinity or negative infinity ; false otherwise.
public static boolean isInfinite(double v)Returns true if the value of the argument is positive infinity or negative infinity ; false otherwise.
Parameter Description v the value to be tested
public boolean isNaN()Returns true if the value represented by this object is NaN ; false otherwise.
public static boolean isNaN(double v)Returns true if the value of the argument is NaN ; false otherwise.
Parameter Description v the value to be tested
public static double longBitsToDouble(long bits)The argument is considered to be a representation of a floating-point value according to the IEEE 754 floating-point "double precision" bit layout. That floating-point value is returned as the result.
If the argument is 0x7f80000000000000L, the result is positive infinity.
If the argument is 0xff80000000000000L, the result is negative infinity.
If the argument is any value in the range 0x7ff0000000000001L through 0x7fffffffffffffffL or in the range 0xfff0000000000001L through 0xffffffffffffffffL, the result is NaN. All IEEE 754 NaN values are, in effect, lumped together by the Java language into a single value.
Return Value:
Returns the double floating-point value with the same bit pattern.
Parameter Description bits any long integer
public long longValue()Returns the double value represented by this object is converted to type long and the result of the conversion is returned.
Overrides:
longValue in class Number .
public String toString()The primitive double value represented by this object is converted to a string exactly as if by the method toString of one argument .
Return Value:
Returns a String representation of this object.
Overrides:
toString in class Object .
public static String toString(double d)Creates a string representation of the double argument.
The values NaN, NEGATIVE_INFINITY, POSITIVE_INFINITY, -0.0, and +0.0 are represented by the strings "NaN", "-Infinity", "Infinity", "-0.0" and "0.0", respectively.
If d is in the range 10-3 £ |d| £ 107, then it is converted to a string in the style [-]ddd.ddd. Otherwise, it is converted to a string in the style [-]m.ddddE±xx.
There is always a minimum of one digit after the decimal point. The number of digits is the minimum needed to uniquely distinguish the argument value from adjacent values of type double.
Return Value:
Returns a string representation of the argument.
Parameter Description d the double to be converted
public static Double valueOf(String s)throws NumberFormatExceptionParses a string into a Double.
Return Value:
Returns a newly constructed Double initialized to the value represented by the string argument..
Parameter Description s the string to be parsed Throw:
If the string does not contain a parsable number.