Package java.lang Previous
Previous
Java API
Java API
Index
Index
Next
Next

Class Double

Fields , Constructors , Methods

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.


Fields


MAX_VALUE

public final static double 
        MAX_VALUE = 1.79769313486231570e+308d 

The largest positive value of type double.


MIN_VALUE

public final static double 
        MIN_VALUE = 4.94065645841246544e-324 

The smallest positive finite value of type double.


NaN

public final static double NaN = 0.0 / 0.0 

A Not-a-Number value of type double.


NEGATIVE_INFINITY

public final static double 
        NEGATIVE_INFINITY = -1.0 / 0.0 

The negative infinity of type double.


POSITIVE_INFINITY

public final static double 
        POSITIVE_INFINITY = 1.0 / 0.0 

The positive infinity of type double.


Constructors


Double

public Double(double  value) 

Constructs a newly allocated Double object that represents the primitive double argument.

ParameterDescription
value the value to be represented by the Double


Double

public Double(String  s) 
throws NumberFormatException 

Constructs 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 .

ParameterDescription
s a string to be converted to a Double

Throw:

NumberFormatException

If the string does not contain a parsable number.


Methods


doubleToLongBits

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.

ParameterDescription
value a double precision floating point number


doubleValue

public double doubleValue() 

Return Value:

Returns the double value represented by this object.

Overrides:

doubleValue in class Number .


equals

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:

Return Value:

Returns true if the objects are the same; false otherwise.

ParameterDescription
obj the object to compare with

Overrides:

equals in class Object .


floatValue

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 .


hashCode

public int hashCode() 

Return Value:

Returns a hash code value for this object.

Overrides:

hashCode in class Object .


intValue

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 .


isInfinite

public boolean isInfinite() 

Returns true if the value represented by this object is positive infinity or negative infinity ; false otherwise.


isInfinite

public static boolean isInfinite(double  v) 

Returns true if the value of the argument is positive infinity or negative infinity ; false otherwise.

ParameterDescription
v the value to be tested


isNaN

public boolean isNaN() 

Returns true if the value represented by this object is NaN ; false otherwise.


isNaN

public static boolean isNaN(double  v) 

Returns true if the value of the argument is NaN ; false otherwise.

ParameterDescription
v the value to be tested


longBitsToDouble

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.

ParameterDescription
bits any long integer


longValue

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 .


toString

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 .


toString

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.

ParameterDescription
d the double to be converted


valueOf

public static Double valueOf(String  s) 
throws NumberFormatException 

Parses a string into a Double.

Return Value:

Returns a newly constructed Double initialized to the value represented by the string argument..

ParameterDescription
s the string to be parsed

Throw:

NumberFormatException

If the string does not contain a parsable number.



Top© 1996 Sun Microsystems, Inc. All rights reserved.