Double.doubleToLongBits() in Java

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

Syntax:

long java.lang.Double.doubleToLongBits(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.

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 0x7ff8000000000000L.

Parameters: One parameter is required for this method.

value: a double-precision floating-point number.

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

For Example:

double value = 16.5

Double.doubleToLongBits(value) = > It returns 4625337554797854720.

Approach

Java

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

        double value = 16.5;
        System.out.println(Double.doubleToLongBits(value));

    }
}

Output:

4625337554797854720

No comments:

Post a Comment