Javatpoint Logo
Javatpoint Logo

Java Double doubleToLongBits() method

The doubleToLongBits() method of Java Double class returns a floating-point value according to the IEEE 754 floating-point "double format" bit layout.

Syntax

Parameters

Value is the double parameter passed which is a double precision floating-point number.

Return value

The doubleToLongBits(double value) method returns the bits that represent the floating-point number.

  • If the argument is positive infinity, the result returned is 0x7ff0000000000000L.
  • If the argument is negative infinity, the result returned is 0xfff0000000000000L.
  • If the argument is NaN, the result returned is 0x7ff8000000000000L.

Example 1

Test it Now

Output:

5.5 value in long bits = 4617878467915022336
NaN value in long bits =9221120237041090560
Infinity value in long bits =9218868437227405312
-Infinity value in long bits=-4503599627370496

Example 2

Test it Now

Output:

-6.58768566756756E7 value in long bits = -4499261384967075684

Example 3

Test it Now

Output:

Error:(13, 43) java: incompatible types: long cannot be converted to java.lang.Double

Here, we are converting it into long bits and then putting it into double without an explicit cast. Either we should put it into long or should directly call this method in println function otherwise, you will get an error.


Next TopicJava Double





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA