Facebook Page Twitter Page LinkedIn Page
× Java.lang Package Classes


The java.lang.Double.longBitsToDouble() method is used to return 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. It includes the following important points:

  • If the argument is 0x7ff0000000000000L, the result is positive infinity.
  • If the argument is 0xfff0000000000000L, 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 a NaN. No IEEE 754 floating-point operation provided by Java can distinguish between two NaN values of the same type with different bit patterns. Distinct values of NaN are only distinguishable by use of the Double.doubleToRawLongBits method.

Syntax

public static double longBitsToDouble(long bits)

Parameters

bits Specify any long integer.

Return Value

Returns the double floating-point value with the same bit pattern.

Exception

NA.

Example:

In the below example, the java.lang.Double.longBitsToDouble() method is used to return the double floating-point value with the given bit pattern.

import java.lang.*;

public class MyClass {
  public static void main(String[] args) {

    //creating long bits
    long x = 25;
    long y = -25;

    //printing the double floating-point value representing x
    System.out.print("longBitsToDouble value of x is: ");
    System.out.println(Double.longBitsToDouble(x)); 

    //printing the double floating-point value representing y
    System.out.print("longBitsToDouble value of y is: "); 
    System.out.println(Double.longBitsToDouble(y));
  }
}

The output of the above code will be:

longBitsToDouble value of x is: 1.24E-322
longBitsToDouble value of y is: NaN

❮ Java.lang - Double