Doubles take up twice the amount of memory as floats do (hence the name) but as a result they are more precise and can represent a wider range of values. Memory space doesn’t matter as much as it used to so for most use cases, doubles are just fine. In certain applications though where speed and performance is a higher priority than accuracy, such as graphics calculations for video games, using floats instead of doubles may be preferable. Answer from Quantum-Bot on reddit.com
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › Double.html
Double (Java Platform SE 8 )
October 20, 2025 - Java™ Platform Standard Ed. 8 ... The Double class wraps a value of the primitive type double in an object.
Discussions

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
[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
July 2, 2021
Can't open .jar files by double clicking them?
Double clicking a jar file should cause it to run.. By the sound of it, it is running? If a window is popping up, that means the program is running, right? If you want something to actually open, run it using java -jar (jar-name) to view the console output. If you're running something that should be making a gui but isn't (like javafx/swing etc) please provide more information. If your program is simply a CLI application, it's working as intended. You double click it, it runs through main method, and does everything it has to, then terminates. You can ensure that it's actually running by making a program which creates a blank .txt file in that directory. If you -need- to see the console output (and can't make it write a log to a file etc), do one of the following: Create a simple .bat file. (Will be double-clickable like a program, but will simply open up a console window and run the program inside of it.) run it in a terminal (java -jar (jarname)) More on reddit.com
🌐 r/javahelp
5
2
August 1, 2019
Java: Comparing two numbers of type double to three decimal places using a boolean value
Try to find a math formula to solve the problem. Maybe, knowing the Math.abs() in Java will be useful ... More on reddit.com
🌐 r/learnprogramming
8
1
January 20, 2019
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.

🌐
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.
🌐
W3Schools
w3schools.com › java › ref_keyword_double.asp
Java double Keyword
Java Examples Java Videos 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....
🌐
OpenJDK
openjdk.org › jeps › 8344154
JEP draft: Convenience Methods for JSON Documents
2 days ago - toDouble() asserts that the JsonValue is a JsonNumber, and if its numeric value can be represented accurately as a Java double, returns it as a double value.
Find elsewhere
🌐
Coderanch
coderanch.com › t › 715999 › java › double
End your double value with 'd' (Beginning Java forum at Coderanch)
September 8, 2019 - Example: double value = 11.99d; Thank you. ... In the code that I have come across, I almost never see it specified. ... I have never seen 'd' used in production level code. It just gives the reader's brain one more thing to parse and slows down the reading process. JavaRanch-FAQ HowToAskQuestionsOnJavaRanch UseCodeTags DontWriteLongLines ItDoesntWorkIsUseLess FormatCode JavaIndenter SSCCE API-17 JLS JavaLanguageSpecification MainIsAPain KeyboardUtility
🌐
Baeldung
baeldung.com › home › java › java numbers › comparing doubles in java
Comparing Doubles in Java | Baeldung
December 11, 2025 - The recommended algorithm to compare double values in plain Java is a threshold comparison method.
🌐
PW Skills
pwskills.com › blog › java developer › java type casting
Java Type Casting
3 weeks ago - Because the new container is bigger than the old one, there is no risk of losing data. Java handles this mechanism for you, so you do not need to write any extra code. The hierarchy for widening casting follows this order: byte -> short -> char -> int -> long -> float -> double
🌐
Programming.Guide
programming.guide › java › double-vs-double.html
Java: Double (class) vs double (primitive) | Programming.Guide
Double is the wrapper type for the primitive type double. Objects of type Double are often referred to as boxed values. The fundamental difference is that Double is a class defined in the standard library, while double is part of the language itself.
🌐
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.
🌐
CodeGym
codegym.cc › java blog › java numbers › java double keyword
Java double keyword
February 19, 2025 - Java provides primitive data types like double for efficiency and simplicity. They aren’t objects, so they don’t come with object-oriented features. On the flip side, wrapper classes like Double wrap those primitive values in an object. That means you can store them in data structures that only accept objects, such as Collections.
🌐
Android Developers
developer.android.com › api reference › double
Double | API reference | Android Developers
Skip to main content · English · Deutsch · Español – América Latina · Français · Indonesia · Polski · Português – Brasil · Tiếng Việt · 中文 – 简体
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › java.lang.double
Double Class (Java.Lang) | Microsoft Learn
The Double class wraps a value of the primitive type double in an object. [Android.Runtime.Register("java/lang/Double", DoNotGenerateAcw=true)] public sealed class Double : Java.Lang.Number, IConvertible, IDisposable, Java.Interop.IJavaPeerable, ...
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-lang-double-class-java
Java.Lang.Double Class in Java - GeeksforGeeks
July 23, 2025 - Java Collection · Last Updated : 23 Jul, 2025 · Double class is a wrapper class for the primitive type double which contains several methods to effectively deal with a double value like converting it to a string representation, and vice-versa.
🌐
DigitalOcean
digitalocean.com › community › tutorials › java-convert-string-to-double
Java Convert String to double | DigitalOcean
August 3, 2022 - Java String to double conversion can be done by many ways. Today we will look into some common ways to convert java string to double primitive data type or Double object.
🌐
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.
🌐
Groovy
docs.groovy-lang.org › docs › groovy-4.0.26 › html › groovy-jdk › java › lang › Double.html
Double (Groovy JDK enhancements)
Compares this object against the specified object returning the same result as Double#equals(Object) but returning true if this object and the specified object are both zero and negative zero respectively or vice versa.
🌐
W3Schools
w3schools.com › java › java_data_types.asp
Java Data Types
Note: This rule makes Java safer, because the compiler will stop you if you try to mix up types by mistake. If you really need to change between types, you must use type casting or conversion methods (for example, turning an int into a double).
🌐
Dutch Bros
dutchbros.com › menu › blended-freeze
Blended Freeze - Blended coffee perfection paired with your favorite flavor. - Dutch Bros Coffee
Creamy Espresso, Extra Double Shot Espresso, Vanilla & Chocolate Milk · Creamy Espresso, Extra Double Shot Espresso & Irish Cream · Creamy Espresso & Chocolate Milk · Creamy Espresso, White Chocolate & Chocolate Milk · Creamy Espresso, Vanilla, Chocolate Macadamia Nut, Chocolate Milk w/ ...