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

Java doubles and 0.0
Does it do two checks if you do a zero comparison with a double? ... For pretty much everything that you try and fail, you can safely assume someone else tried and failed before, and wrote about it at the Internet. First hit was https://stackoverflow.com/questions/39933792/how-do-i-check-for-a-negative-zero-in-java... More on gamedev.net
🌐 gamedev.net
15
January 14, 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
[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 4, 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
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.

🌐
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....
🌐
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.
🌐
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.
Find elsewhere
🌐
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 · 中文 – 简体
🌐
GameDev.net
gamedev.net › forums › topic › 715430-java-doubles-and-00
Java doubles and 0.0 - For Beginners - GameDev.net
January 14, 2024 - You can read the basis of it for Java 21 here, but this specific behavior has been the same since the beginning of the language. Look down a few paragraphs to read “Positive zero and negative zero compare equal, so the result of the expression 0.0==-0.0 is true and the result of 0.0>-0.0 is false.
🌐
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.
🌐
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, ...
🌐
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/ ...
🌐
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.
🌐
Quora
quora.com › Why-does-Java-use-double-for-floating-point-numbers-instead-of-long-for-scientific-calculations
Why does Java use double for floating point numbers instead of long for scientific calculations? - Quora
Answer: Usage of floating point arithmetics in scientific calculations is not related to Java. Floating points are able to represent real number with varying precision for different magnitudes: number with smaller magnitudes are represented with higher precision and numbers with large magnitudes...
🌐
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 - Junilu Lacar wrote:the compiler probably generates bytecode to invoke d2.doubleValue() to unbox it If you follow the link Campbell provided to the JLS section on unboxing conversions, you'll see my guess was right: The Java Language Specification 5.1.8 wrote:If r is a reference of type Double, then unboxing conversion converts r into r.doubleValue()
🌐
Simplilearn
simplilearn.com › home › resources › software development › float vs double in java: key differences you should know
Float vs Double in Java: Key Differences You Should Know
November 17, 2025 - Explore the key differences between float and double in Java. Our comprehensive guide helps you choose the right type for your Java applications. Perfect for new coders!
🌐
Java
download.java.net › java › early_access › loom › docs › api › java.base › java › lang › Double.html
Double (Java SE 25 & JDK 25 [build 1])
P where Sign, FloatingPointLiteral, HexNumeral, HexDigits, SignedInteger and FloatTypeSuffix are as defined in the lexical structure sections of The Java Language Specification, except that underscores are not accepted between digits. If s does not have the form of a FloatValue, then a NumberFormatException is thrown. Otherwise, s is regarded as representing an exact decimal value in the usual "computerized scientific notation" or as an exact hexadecimal value; this exact numerical value is then conceptually converted to an "infinitely precise" binary value that is then rounded to type double by the usual round-to-nearest rule of IEEE 754 floating-point arithmetic, which includes preserving the sign of a zero value.