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

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

  • 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 the long integer representing the actual NaN value. Unlike the doubleToLongBits method, doubleToRawLongBits does not collapse all the bit patterns encoding a NaN to a single "canonical" NaN value.


public static long doubleToRawLongBits(double value)


value Specify a double precision floating-point number.

Return Value

Returns the bits that represent the floating-point number.




In the below example, the java.lang.Double.doubleToRawLongBits() method is used to return the bits that represent the given floating-point number.

import java.lang.*;

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

    //creating double values
    double x = 25;
    double y = -25;

    //printing the bit which represents x
    System.out.print("doubleToRawLongBits value of x is: ");

    //printing the bit which represents y
    System.out.print("doubleToRawLongBits value of y is: "); 

The output of the above code will be:

doubleToRawLongBits value of x is: 4627730092099895296
doubleToRawLongBits value of y is: -4595641944754880512

❮ Java.lang - Double