![]() |
VOOZH | about |
Double class is a wrapper class for the primitive type double which contains several methods to effectively deal with a double value like converting it to a string representation, and vice-versa. An object of the Double class can hold a single double value. Double class is a wrapper class for the primitive type double which contains several methods to effectively deal with a double value like converting it to a string representation, and vice-versa. An object of the Double class can hold a single double value.
There are mainly two constructors to initialize a Double-object.
A. Double(double b): Creates a Double-object initialized with the value provided where it takes a value with which to initialize as a parameter.
public Double(double d)
Parameters: Value with which to initialize
B. Double(String s): Creates a Double-object initialized with the parsed double value provided by string representation where it takes a string representation of the byte value as a parameter.
Default radix is taken to be 10.
public Double(String s) throws NumberFormatException
Exception Thrown: It throws NumberFormatException if the string provided does not represent any double value.
| Method | Action Performed |
|---|---|
| byteValue() | Returns a byte value corresponding to this Double Object |
| compare() | Compare two primitive double values for numerical equality. As it is a static method therefore it can be used without creating any object of Double. |
| compareTo() | Used to compare two Double objects for numerical equality and returns a value less than 0,0, a value greater than 0 for less than, equal to, and greater than. |
| doubleValue() | Returns a double value corresponding to this Double Object. |
| doubleToLongBits() | Returns the IEEE 754 floating-point "double format" bit layout of the given double argument. |
| doubleToRawLongBits() | Returns the IEEE 754 floating-point "double format" bit layout of the given double argument. It differs from the previous method as it preserves the Nan values. |
| equals() | Compare the equality of two Double objects and returns true if both the objects contain same double value. |
| floatValue() | Returns a float value corresponding to this Double Object. |
| hashCode() | Returns the hashcode corresponding to this Double Object. |
| isInfinite() | Returns true if the double object in consideration is very large, otherwise false. |
| isNaN() | Returns true if the double object in consideration is not a number, otherwise false. |
| intValue() | Returns an integer value corresponding to this Double Object |
| longValue() | Returns long value corresponding to this Double Object. |
| longBitsToDouble() | Returns double value corresponding to the long bit pattern of the argument. |
| parseDouble() | Returns double value by parsing the string. |
| shortValue() | Returns short value corresponding to this Double Object |
| toHexString() | Returns hexadecimal representation of the argument double value. |
| toString() | Returns the string corresponding to the double value |
| valueOf() | Returns a Double-object initialized with the value provided |
| valueOf(String s) | Returns a Double-object initialized with the value provided |
Output
toString(b) = 55.05 valueOf(b) = 55.05 ValueOf(bb) = 45.0 parseDouble(bb) = 45.0 bytevalue(x) = 55 shortvalue(x) = 55 intvalue(x) = 55 longvalue(x) = 55 doublevalue(x) = 55.05 floatvalue(x) = 55.05 hashcode(x) = 640540672 x.equals(y) = false compare(x,y) = 1 x.compareTo(y) = 1 isNaN(d) = false Double.isNaN(45.12452) = false Double.isInfinite(d) = true Double.toString(dd) = 0x1.4029b7564302bp13 Double.doubleToLongBits(dd) = 4666857980575363115 Double.LongBitsToDouble(double_to_long) = 10245.21452