Double.longBitsToDouble(): This method is available in java.lang.Double class of Java.
Syntax:
double java.lang.Double.longBitsToDouble(long bits)
This method takes one argument of type long as its parameter. This method returns the double value corresponding to a given bit representation. The argument is considered to be a representation of a floating-point value according to the IEEE 754 floating-point"double format" bit layout.
Note:
1. If the argument is 0x7ff0000000000000L, the result is positive infinity.
2. If the argument is 0xfff0000000000000L, the result is negative infinity.
3. If the argument is any value in the range 0x7ff0000000000001L through 0x7fffffffffffffffL or in the range 0xfff0000000000001L through 0xffffffffffffffffL, the result is a NaN.
Parameters: bits any long integer.
Returns: the double floating-point value with the same bit pattern.
For Example:
long bits = 18818
Double.longBitsToDouble(bits) = > It returns 9.2973E-320.
Approach
Java
public class DoublelongBitsToDouble {public static void main(String[] args) {long bits = 18818;System.out.println(Double.longBitsToDouble(bits));}}
Output:
9.2973E-320
No comments:
Post a Comment