Java Double doubleToLongBits() methodThe doubleToLongBits() method of Java Double class returns a floating-point value according to the IEEE 754 floating-point "double format" bit layout. SyntaxParametersValue is the double parameter passed which is a double precision floating-point number. Return valueThe doubleToLongBits(double value) method returns the bits that represent the floating-point number.
Example 1Output: 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 2Output: -6.58768566756756E7 value in long bits = -4499261384967075684 Example 3Output: 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-doubletorawlongbits-method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India