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

Answer from Saurabh Gokhale on Stack Overflow
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › Double.html
Double (Java Platform SE 8 )
July 21, 2026 - Java™ Platform Standard Ed. 8 ... The Double class wraps a value of the primitive type double in an object.
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.

Discussions

When should I use double and when should I use float for Java?
On July 1st, a change to Reddit's API pricing will come into effect. Several developers of commercial third-party apps have announced that this change will compel them to shut down their apps. At least one accessibility-focused non-commercial third party app will continue to be available free of charge. If you want to express your strong disagreement with the API pricing change or with Reddit's response to the backlash, you may want to consider the following options: Limiting your involvement with Reddit, or Temporarily refraining from using Reddit Cancelling your subscription of Reddit Premium as a way to voice your protest. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/learnprogramming
65
59
January 6, 2024
Should I always use doubles in Java?
Integer division is not necessarily undesirable. And floating points have their own set of quirks that make them potentially unsuitable for things like monetary calculations without specific handling (for monetary values, most software stores them as integer numbers of cents rather than floats for efficiency and precision reasons). More on reddit.com
🌐 r/learnprogramming
7
2
February 19, 2022
Why is a double preferred over a float?

Dealing with any type of floating point numbers is a science as they are not exact. Essentially it boils down to doubles being accurate to a greater number of decimal places and if you are using a JVM memory is not likely to be a problem.

If you are doing finance type tasks there are specific classes that should be used - the same as if the data is to be stored in a database - which will guarantee accuracy of your decimal places (up to a specified point)

More on reddit.com
🌐 r/java
12
1
October 24, 2011
[New CS Student]Trouble differentiating between floats and doubles--why is 23.5 considered a double?
Every decimal number literal will be considered a double by default unless specified as float with the f. Same goes for whole numbers being integers by default. More on reddit.com
🌐 r/learnjava
7
5
August 7, 2021
🌐
W3Schools
w3schools.com › java › ref_keyword_double.asp
Java double Keyword
The double keyword is a data type that can store fractional numbers from 1.7e−308 to 1.7e+308.
🌐
TheServerSide
theserverside.com › blog › Coffee-Talk-Java-News-Stories-and-Opinions › Float-vs-Double-Whats-the-difference
Java double vs float: What's the difference?
A double is twice the size of a float — thus the term double. In Java, the Float and Double wrapper classes have two properties that return the upper and lower limits of float and double data types, MIN_VALUE and MAX_VALUE:
Published: May 23, 2026
🌐
Oracle
docs.oracle.com › javase › 7 › docs › api › java › lang › Double.html
Double (Java Platform SE 7 )
Java™ Platform Standard Ed. 7 ... The Double class wraps a value of the primitive type double in an object.
🌐
Oracle
docs.oracle.com › javase › 6 › docs › api › java › lang › Double.html
Double (Java Platform SE 6)
Compares two Double objects numerically. There are two ways in which comparisons performed by this method differ from those performed by the Java language numerical comparison operators (<, <=, ==, >= >) when applied to primitive double values:
🌐
Software Testing Help
softwaretestinghelp.com › home › java › java double – tutorial with programming examples
Java Double - Tutorial With Programming Examples
April 1, 2025 - In the below example, we have defined a pattern delimited by comma ‘,’ and a decimal number of type double. Using this pattern or format, we are going to display our input number. We have passed the pattern into the Decimal format class and we have formatted the output using the reference ‘df’. import java.text.DecimalFormat; public class ExampleFormat { public static void main(String[] args) { // defining a format in which number will be displayed String formatter = "##,###,###.##"; // initialized the decimal number double num = 12345678.12; // passed the pattern into the Decimal format class DecimalFormat df = new DecimalFormat(formatter); // printed the formatted number System.out.println("The formatted number is: " +df.format(num)); } }
Find elsewhere
🌐
Oracle
docs.oracle.com › en › java › javase › 17 › docs › api › java.base › java › lang › Double.html
Double (Java SE 17 & JDK 17)
April 21, 2026 - Compares two Double objects numerically. This method imposes a total order on Double objects with two differences compared to the incomplete order defined by the Java language numerical comparison operators (<, <=, ==, >=, >) on double values.
🌐
Baeldung
baeldung.com › home › java › java numbers › float vs. double in java
Float vs. Double in Java | Baeldung
January 4, 2025 - Java provides two primitive data types for floating-point arithmetic: float and double. Both adhere to the IEEE 754 standard, ensuring consistent behavior across platforms.
🌐
DataCamp
datacamp.com › doc › java › double
double Keyword in Java: Usage & Examples
Java keywordsIntroduction To JavaJava File HandlingJava Language BasicsJava ArraysJava Object-Oriented Programming ... The double keyword in Java is a primitive data type that represents a double-precision 64-bit IEEE 754 floating point.
🌐
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 - Compares two Double objects numerically. This method imposes a total order on Double objects with two differences compared to the incomplete order defined by the Java language numerical comparison operators (<, <=, ==, >=, >) on double values.
🌐
Tutorialspoint
tutorialspoint.com › java › lang › java_lang_double.htm
Java - Double class
The Java Double class wraps a value of primitive type double in an object.
🌐
Oracle
docs.oracle.com › en › java › javase › 23 › docs › api › java.base › java › lang › Double.html
Double (Java SE 23 & JDK 23)
October 17, 2024 - Compares two Double objects numerically. This method imposes a total order on Double objects with two differences compared to the incomplete order defined by the Java language numerical comparison operators (<, <=, ==, >=, >) on double values.
🌐
Java
download.java.net › java › early_access › valhalla › docs › api › java.base › java › lang › Double.html
Double (Java SE 23 & JDK 23 [build 1])
Compares two Double objects numerically. This method imposes a total order on Double objects with two differences compared to the incomplete order defined by the Java language numerical comparison operators (<, <=, ==, >=, >) on double values.
🌐
CodeGym
codegym.cc › java blog › java numbers › java double keyword
Java double keyword
February 19, 2025 - The Java double keyword, as in any other language, indicates a computer format for representing a floating point number, occupying 64 bits, or 8 bytes, in memory. In this article we are going to talk...
🌐
Coderanch
coderanch.com › t › 750518 › java › difference-double-Double-java
What is the difference between 'double' and 'Double' in java? (Beginning Java forum at Coderanch)
March 25, 2022 - In general you use the built in type "double" unless you specifically need an Object, such as when adding to a Collection. JavaRanch-FAQ HowToAskQuestionsOnJavaRanch UseCodeTags DontWriteLongLines ItDoesntWorkIsUseLess FormatCode JavaIndenter SSCCE API-17 JLS JavaLanguageSpecification MainIsAPain KeyboardUtility
🌐
Wikibooks
en.wikibooks.org › wiki › Java_Programming › Keywords › double
Java Programming/Keywords/double - Wikibooks, open books for an open world
The java.lang.Double class is the nominal wrapper class when you need to store a double value but an object reference is required.