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
🌐
W3Schools
w3schools.com › java › ref_keyword_double.asp
Java double Keyword
Java Examples Java Videos Java ... Study Plan Java Interview Q&A ... The double keyword is a data type that can store fractional numbers from 1.7e−308 to 1.7e+308....
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › Double.html
Double (Java Platform SE 8 )
April 21, 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. If the argument is any value in the range 0x7ff0000000000001L through 0x7fffffffffffffffL or in the range 0xfff0000000000001L through 0xffffffffffffffffL, the result is a NaN. No IEEE 754 floating-point operation provided by Java can distinguish between two NaN values of the same type with different bit patterns.
🌐
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.
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.

🌐
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:
Find elsewhere
🌐
Home and Learn
homeandlearn.co.uk › java › double_variables.html
java for complete beginners - double variables
Change the int from your previous code to double. So change this: ... Leave the rest of the programme as it is. Your coding window should look like this: Run your programme again. The output window should look like this: Try changing the values stored in first_number and second_number. Use any values you like. Run your programme and see what happens. In the next part, you'll learn about two more Java variable types: short and float.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-lang-double-class-java
Java.Lang.Double Class in Java - GeeksforGeeks
July 23, 2025 - B. Double(String s): Creates a Double-object initialized with the parsed double value provided by string representation where it takes a string representation of the byte value as a parameter.
🌐
Baeldung
baeldung.com › home › java › java numbers › float vs. double in java
Float vs. Double in Java | Baeldung
January 4, 2025 - This article explores these differences in detail, aiming to guide developers in choosing the right type for tasks such as scientific computations, graphics processing, and financial analyses. Java provides two primitive data types for floating-point arithmetic: float and double.
🌐
Scaler
scaler.com › home › topics › float vs double in java - difference you should know
Float Vs Double in Java - Difference You Should Know - Scaler Topics
March 27, 2024 - The double keyword in Java is also a primitive data type, and its size limit is 8 byte or 64 bits double-precision IEEE 754 floating-point number, that is it can allow up to 15 digits precision after the decimal. It also stores the value in decimals or fractions.
🌐
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.
🌐
Reddit
reddit.com › r › golang
The Go Programming Language
November 11, 2009 - But it doesn't do full type erasure like Java either, where the generic parameters are erased and values are boxed behind a common type. Erasure cuts down on duplication but adds some runtime overhead. Instead Go takes a hybrid approach between the two. Type parameters get grouped by GC shape.
🌐
Menu
nationsrestaurants.com › homepage › menu
Menu | Nation’s Giant Hamburgers
March 7, 2025 - Two eggs cooked to order with double serving of breakfast protein of your choice, hash browns, and toast. *Substitute toast and hash browns for 4 pancakes or 2 slices of French toast ...
Price   $
Address   11090 San Pablo Ave., Suite 200, 94530, El Cerrito
🌐
YouTube
youtube.com › alex lee
Double In Java - Double VS Int - YouTube
$1,000 OFF ANY Springboard Tech Bootcamps with my code ALEXLEE. See if you qualify for the JOB GUARANTEE! 👉 https://bit.ly/3HX970hIn this video, I show you ...
Published   June 15, 2023
Views   10K
🌐
Minecraft Wiki
minecraft.fandom.com › wiki › Slab
Slab – Minecraft Wiki
March 18, 2026 - Double slabs drop 2 of their respective single slabs, even when mined with Silk Touch. In Java Edition, double slabs are completely unobtainable.
🌐
Kotlin
kotlinlang.org › docs › basic-syntax.html
Basic syntax overview | Kotlin Documentation
For information about declaring properties, see Properties. ... class Rectangle(val height: Double, val length: Double) { val perimeter = (height + length) * 2 } fun main() { val rectangle = Rectangle(5.0, 2.0) println("The perimeter is ${rectangle.perimeter}") }
🌐
Sololearn
sololearn.com › en › Discuss › 1812370 › what-does-double-do-in-java
What does "double" do in java? | Sololearn: Learn to code for FREE!
May 22, 2019 - *Taken from the JAVA lesson: - double: for floating-point or real numbers with optional decimal points and fractional parts in fixed or scientific notations, such as 3.1416, -55.66.
🌐
Study.com
study.com › business courses › java programming tutorial & training
Java: Float vs. Double - Lesson | Study.com
July 21, 2018 - This lesson has provided an overview of float, which holds 4 bytes of memory (32 bits) and stores about 7 digits, and double, which can hold 8 bytes (64 bits) and store about 15 digits after the decimal point, data types in Java. Both are considered primitive data types because they're core to the language and need nothing special to use them.