Double.doubleToRawLongBits() in Java

Double.doubleToRawLongBits(): This method is available in java.lang.Double class of Java.

Syntax:

long java.lang.Double.doubleToRawLongBits(double value)

This method takes one argument of type double as its parameter. This method 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.

Note:

1. If the argument is positive infinity, the result is 0x7ff0000000000000L.

2. If the argument is negative infinity, the result is 0xfff0000000000000L.

3. If the argument is NaN, the result is the long integer representing the actual NaN value.

Parameters: value a double-precision floating-point number.

Returns: the bits that represent the floating-point number.

For Example:

double value = 15.6

Double.doubleToRawLongBits(value) = > It returns 4624971637328130867.

Approach

Java

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

        double value = 15.6;
        System.out.println(Double.doubleToRawLongBits(value));

    }
}

Output:

4624971637328130867

No comments:

Post a Comment