🌐
Tutorialspoint
tutorialspoint.com › home › java/lang › java double value method
Java Double Value Method
September 1, 2008 - This method returns the double value after conversion. The following example shows the usage of Java Number doubleValue() method. Here, we are instantiating an Integer object and initializing it. The method is then invoked on this object.
🌐
Javatpoint
javatpoint.com › double-keyword-in-java
Java double keyword - Javatpoint
Java double keyword - The Java double keyword is a primitive data type. It is a double-precision 64-bit IEEE 754 floating point. It is used to declare the variables and methods. It generally represents the decimal numbers.
🌐
Javatpoint
javatpoint.com › java-double-doublevalue-method
Java Double doubleValue() Method - Javatpoint
Syntax: public static double sum(double a, double b) Parameters: a- the first argument passed b- the second argument passed Return Value: The sum() method returns the sum of a and b. Example 1 import... ... We provides tutorials and interview questions of all technology like java tutorial, ...
🌐
Oracle
docs.oracle.com › javase › 7 › docs › api › java › lang › Double.html
Double (Java Platform SE 7 )
int s = ((bits >> 63) == 0) ? 1 : -1; int e = (int)((bits >> 52) & 0x7ffL); long m = (e == 0) ? (bits & 0xfffffffffffffL) &lt;< 1 : (bits & 0xfffffffffffffL) | 0x10000000000000L; Then the floating-point result equals the value of the mathematical expression s·m·2e-1075. Note that this method may not be able to return a double NaN with exactly same bit pattern as the long argument. IEEE 754 distinguishes between two kinds of NaNs, quiet NaNs and signaling NaNs. The differences between the two kinds of NaN are generally not visible in Java.
🌐
Tutorialspoint
tutorialspoint.com › java › lang › double_doublevalue.htm
Java - Double doubleValue() method
Then using doubleValue() method, we're printing its value. package com.tutorialspoint; public class DoubleDemo { public static void main(String[] args) { Double d = new Double("15.30"); //return the double value System.out.println("Value = " + d.doubleValue()); } }
🌐
Home and Learn
homeandlearn.co.uk › java › double_variables.html
java for complete beginners - double variables
The double variable is also used to hold floating point values. A floating point value is one like 8.7, 12.5, 10.1. In other words, it has a "point something" at the end. If you try to store a floating point value in an int variable, NetBeans will underline the faulty code.
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › Double.html
Double (Java Platform SE 8 )
October 20, 2025 - int s = ((bits >> 63) == 0) ? 1 : -1; int e = (int)((bits >> 52) & 0x7ffL); long m = (e == 0) ? (bits & 0xfffffffffffffL) << 1 : (bits & 0xfffffffffffffL) | 0x10000000000000L; Then the floating-point result equals the value of the mathematical expression s·m·2e-1075. Note that this method may not be able to return a double NaN with exactly same bit pattern as the long argument. IEEE 754 distinguishes between two kinds of NaNs, quiet NaNs and signaling NaNs. The differences between the two kinds of NaN are generally not visible in Java.
🌐
Software Testing Help
softwaretestinghelp.com › home › java › java double – tutorial with programming examples
Java Double - Tutorial With Programming Examples
April 1, 2025 - Java double is used to represent floating-point numbers. It uses 64 bits to store a variable value and has a range greater than float type.
Top answer
1 of 3
38

Double is a wrapper class,

The Double class wraps a value of the primitive type double in an object. An object of type Double contains a single field whose type is double.

In addition, this class provides several methods for converting a double to a String and a String to a double, as well as other constants and methods useful when dealing with a double.

The double data type,

The double data type is a double-precision 64-bit IEEE 754 floating point. Its range of values is 4.94065645841246544e-324d to 1.79769313486231570e+308d (positive or negative). For decimal values, this data type is generally the default choice. As mentioned above, this data type should never be used for precise values, such as currency.

Check each datatype with their ranges : Java's Primitive Data Types.


Important Note : If you'r thinking to use double for precise values, you need to re-think before using it. Java Traps: double

2 of 3
29

In a comment on @paxdiablo's answer, you asked:

"So basically, is it better to use Double than Float?"

That is a complicated question. I will deal with it in two parts


Deciding between double versus float

On the one hand, a double occupies 8 bytes versus 4 bytes for a float. If you have many of them, this may be significant, though it may also have no impact. (Consider the case where the values are in fields or local variables on a 64bit machine, and the JVM aligns them on 64 bit boundaries.) Additionally, floating point arithmetic with double values is typically slower than with float values ... though once again this is hardware dependent.

On the other hand, a double can represent larger (and smaller) numbers than a float and can represent them with more than twice the precision. For the details, refer to Wikipedia.

The tricky question is knowing whether you actually need the extra range and precision of a double. In some cases it is obvious that you need it. In others it is not so obvious. For instance if you are doing calculations such as inverting a matrix or calculating a standard deviation, the extra precision may be critical. On the other hand, in some cases not even double is going to give you enough precision. (And beware of the trap of expecting float and double to give you an exact representation. They won't and they can't!)

There is a branch of mathematics called Numerical Analysis that deals with the effects of rounding error, etc in practical numerical calculations. It used to be a standard part of computer science courses ... back in the 1970's.


Deciding between Double versus Float

For the Double versus Float case, the issues of precision and range are the same as for double versus float, but the relative performance measures will be slightly different.

  • A Double (on a 32 bit machine) typically takes 16 bytes + 4 bytes for the reference, compared with 12 + 4 bytes for a Float. Compare this to 8 bytes versus 4 bytes for the double versus float case. So the ratio is 5 to 4 versus 2 to 1.

  • Arithmetic involving Double and Float typically involves dereferencing the pointer and creating a new object to hold the result (depending on the circumstances). These extra overheads also affect the ratios in favor of the Double case.


Correctness

Having said all that, the most important thing is correctness, and this typically means getting the most accurate answer. And even if accuracy is not critical, it is usually not wrong to be "too accurate". So, the simple "rule of thumb" is to use double in preference to float, UNLESS there is an overriding performance requirement, AND you have solid evidence that using float will make a difference with respect to that requirement.

Find elsewhere
🌐
Oracle
docs.oracle.com › en › java › javase › 24 › docs › api › java.base › java › lang › Double.html
Double (Java SE 24 & JDK 24)
July 15, 2025 - The argument is considered to be a representation of a floating-point value according to the IEEE 754 floating-point "double format" bit layout. If the argument is 0x7ff0000000000000L, the result is positive infinity. If the argument is 0xfff0000000000000L, the result is negative infinity.
🌐
Tutorialspoint
tutorialspoint.com › java › double_keyword_in_java.htm
Java - double Keyword (double Data Type)
Following is the syntax to declare a double-type variable using the double keyword: ... The default value of a double-type variable is 0.0d, here 'd' represents the double type.
🌐
iO Flood
ioflood.com › blog › java-double
Java Double Keyword: Your Guide to Decimal Precision
February 26, 2024 - The double keyword is used to identify a data type in Java that is used to store decimal numbers, instantiated with the syntax double var = 3.14;. It provides a way to work with numbers that have a decimal point and need a high degree of precision.
🌐
DataCamp
datacamp.com › doc › java › double
double Keyword in Java: Usage & Examples
The double keyword in Java is a primitive data type that represents a double-precision 64-bit IEEE 754 floating point. It is used to store decimal numbers with a higher degree of precision compared to the float data type. The double data type is commonly used in situations that require a large ...
🌐
Oracle
docs.oracle.com › en › java › javase › 21 › docs › api › › java.base › java › lang › Double.html
Double (Java SE 21 & JDK 21)
January 20, 2026 - The argument is considered to be a representation of a floating-point value according to the IEEE 754 floating-point "double format" bit layout. If the argument is 0x7ff0000000000000L, the result is positive infinity. If the argument is 0xfff0000000000000L, the result is negative infinity.
🌐
CodeGym
codegym.cc › java blog › java numbers › java double keyword
Java double keyword
February 19, 2025 - Let's give some examples of using the Java double keyword to create a variable. double myPrice = 5.0; double height = 180; double x = 7.1, y = 3.0; Here in the variable myPrice we have the value 5.0, in the variable height — 180, in x we put ...
🌐
Oracle
docs.oracle.com › javase › 6 › docs › api › java › lang › Double.html
Double (Java Platform SE 6)
int s = ((bits >> 63) == 0) ? 1 : -1; int e = (int)((bits >> 52) & 0x7ffL); long m = (e == 0) ? (bits & 0xfffffffffffffL) &lt;< 1 : (bits & 0xfffffffffffffL) | 0x10000000000000L; Then the floating-point result equals the value of the mathematical expression s·m·2e-1075. Note that this method may not be able to return a double NaN with exactly same bit pattern as the long argument. IEEE 754 distinguishes between two kinds of NaNs, quiet NaNs and signaling NaNs. The differences between the two kinds of NaN are generally not visible in Java.
🌐
Oracle
docs.oracle.com › en › java › javase › 17 › docs › api › java.base › java › lang › Double.html
Double (Java SE 17 & JDK 17)
January 20, 2026 - The argument is considered to be a representation of a floating-point value according to the IEEE 754 floating-point "double format" bit layout. If the argument is 0x7ff0000000000000L, the result is positive infinity. If the argument is 0xfff0000000000000L, the result is negative infinity.
🌐
W3Schools
w3schools.com › java › ref_keyword_double.asp
Java double Keyword
Java Examples Java Videos Java ... Plan Java Interview Q&A Java Certificate ... The double keyword is a data type that can store fractional numbers from 1.7e−308 to 1.7e+308....
🌐
Java
download.java.net › java › early_access › valhalla › docs › api › java.base › java › lang › Double.html
Double (Java SE 23 & JDK 23 [build 1])
Double.compare(a, b) == 0 Note that representation equivalence is often an appropriate notion of equivalence to test the behavior of math libraries. For two binary floating-point values a and b, if neither of a and b is zero or NaN, then the three relations numerical equality, bit-wise equivalence, and representation equivalence of a and b have the same true/false value.
🌐
Tutorialspoint
tutorialspoint.com › home › java/lang › java double class overview
Java Double Class Overview
September 1, 2008 - The Java Double class wraps a value of primitive type double in an object.