Double doubleToLongBits() method in Java with examples Last Updated : 26 Oct, 2018 Comments Improve Suggest changes Like Article Like Report The java.lang.Double.doubleToLongBits() method of Java Double class is a built-in function in java that returns a representation of the specified floating-point value according to the IEEE 754 floating-point "double format" bit layout. Syntax: public static long doubleToLongBits(double val) Parameter: The method accepts only one parameter val which specifies a double precision floating-point number. Return Values: The function returns the bits that represent the floating-point number. Below are the special cases: If the argument is positive infinity, the result is 7ff0000000000000L. If the argument is negative infinity, the result is 0xfff0000000000000L. If the argument is NaN, the result is 0x7ff8000000000000L. Below programs illustrates the use of java.lang.Double.doubleToLongBits() method: Program 1: java // Java program to demonstrate // Double.doubleToLongBits() method import java.lang.*; class Gfg1 { public static void main(String args[]) { double val = 1.5d; // function call long answer = Double.doubleToLongBits(val); // print System.out.println(val + " in long bits: " + answer); } } Output: 1.5 in long bits: 4609434218613702656 Program 2: Java // Java program to demonstrate // Double.doubleToLongBits() method import java.lang.*; class Gfg1 { public static void main(String args[]) { double val = Double.POSITIVE_INFINITY; double val1 = Double.NEGATIVE_INFINITY; double val2 = Double.NaN; // function call long answer = Double.doubleToLongBits(val); // print System.out.println(val + " in long bits: " + answer); // function call answer = Double.doubleToLongBits(val1); // print System.out.println(val1 + " in long bits: " + answer); // function call answer = Double.doubleToLongBits(val2); // print System.out.println(val2 + " in long bits: " + answer); } } Output: Infinity in long bits: 9218868437227405312 -Infinity in long bits: -4503599627370496 NaN in long bits: 9221120237041090560 Reference: https://docs.oracle.com/javase/7/docs/api/java/lang/Double.html#doubleToLongBits(double) Comment More infoAdvertise with us Next Article Double doubleToLongBits() method in Java with examples gopaldave Follow Improve Article Tags : Java java-basics Java-lang package Java-Functions Java-Double +1 More Practice Tags : Java Similar Reads Double doubleToRawLongBits() method in Java with examples The doubleToRawLongBits() method of Java Double class is a built-in function in java that 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. Syntax: public static long doubleToRawLon 2 min read Double byteValue() Method in Java with Examples The Double.byteValue() is a built-in method in Java Double class. This method converts the value of a Double object to a byte type. Basically, it is used for narrowing the primitive conversion of the Double type to a byte value.In this article, we are going to learn about the Double.byteValue() meth 3 min read Byte doubleValue() method in Java with examples The doubleValue() method of Byte class is a built in method in Java which is used to return the value of this Byte object as double. Syntax ByteObject.doubleValue() Return type: It returns the value of ByteObject as double. Below is the implementation of doubleValue() method in Java: Example 1: Java 2 min read Short doubleValue() method in Java with Examples The java.lang.Short.doubleValue() method of Short class is a built in method in Java which is used to return the value of the Short object as a double. Syntax: public double doubleValue() Return type: It return the value of ShortObject as double. Below is the implementation of doubleValue() method i 2 min read AtomicLong doubleValue() method in Java with examples The Java.util.concurrent.atomic.AtomicLong.doubleValue() is an inbuilt method in java which returns the current value of the AtomicLong as a Double data-type after performing primitive conversion. Syntax: public double doubleValue() Parameters: The function does not accepts any parameter. Return val 1 min read Like