Double class

                             
    java.lang.Object                        
     |                       
     |--java.lang.Number                    
         |                   
         |--java.lang.Double                
                             

The Double 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.

Double class provides several methods for converting a double to a String and a String to a double.

Constants in Double class

TypeFieldSummary
static intMAX_EXPONENTMaximum exponent a finite double variable may have.
static doubleMAX_VALUEA constant holding the largest positive finite value of type double.
static intMIN_EXPONENTMinimum exponent a normalized double variable may have.
static doubleMIN_NORMALA constant holding the smallest positive normal value of type double.
static doubleMIN_VALUEA constant holding the smallest positive nonzero value of type double.
static doubleNaNA constant holding a Not-a-Number (NaN) value of type double.
static doubleNEGATIVE_INFINITYA constant holding the negative infinity of type double.
static doublePOSITIVE_INFINITYA constant holding the positive infinity of type double.
static intSIZEThe number of bits used to represent a double value.
static ClassTYPEThe Class instance representing the primitive type double.

Double class Constructor

ConstructorSummary
Double(double value)Creates a Double object that represents the primitive double argument.
Double(String s)Creates a Double object that represents the double value represented by the string.

Return double value as byte, double, float, int, long, short

ReturnMethodSummary
bytebyteValue()Returns the value of this Double as a byte (by casting to a byte).
doubledoubleValue()Returns the double value of this Double object.
floatfloatValue()Returns the float value of this Double object.
intintValue()Returns the value of this Double as an int (by casting to type int).
longlongValue()Returns the value of this Double as a long (by casting to type long).
shortshortValue()Returns the value of this Double as a short (by casting to a short).

Compare two double values

ReturnMethodSummary
static intcompare(double d1, double d2)Compares the two specified double values.
intcompareTo(Double anotherDouble)Compares two Double objects numerically.
booleanequals(Object obj)Compares this object against the specified object.

If a double value is an infinite large value, or it is not a number.

ReturnMethodSummary
booleanisInfinite()Returns true if this Double value is infinitely large in magnitude, false otherwise.
static booleanisInfinite(double v)Returns true if the specified number is infinitely large in magnitude, false otherwise.
booleanisNaN()Returns true if this Double value is a Not-a-Number (NaN), false otherwise.
static booleanisNaN(double v)Returns true if the specified number is a Not-a-Number (NaN) value, false otherwise.

Convert string value to double

ReturnMethodSummary
static doubleparseDouble(String s)Returns a new double initialized to the value represented by the specified String, as performed by the valueOf method of class Double.
static DoublevalueOf(double d)Returns a Double instance representing the specified double value.
static DoublevalueOf(String s)Returns a Double object holding the double value represented by the argument string s.

Convert double value from string

ReturnMethodSummary
StringtoString()Returns a string representation of this Double object.
static StringtoString(double d)Returns a string representation of the double argument.

Get the hexadecimal string representation

ReturnMethodSummary
static StringtoHexString(double d)Returns a hexadecimal string representation of the double argument.

Bit oriented

ReturnMethodSummary
static longdoubleToLongBits(double value)Returns a representation of the specified floating-point value according to the IEEE 754 floating-point "double format" bit layout.
static longdoubleToRawLongBits(double value)Returns a representation of the specified floating-point value according to the IEEE 754 floating-point "double format" bit layout, preserving Not-a-Number (NaN) values.
static doublelongBitsToDouble(long bits)Returns the double value corresponding to a given bit representation.
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.