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 › tutorial › java › nutsandbolts › datatypes.html
Primitive Data Types (The Java™ Tutorials > Learning the Java Language > Language Basics)
This data type should never be ... and other useful classes provided by the Java platform. double: The double data type is a double-precision 64-bit IEEE 754 floating point....
🌐
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.
Discussions

floating point - Float and double datatype in Java - Stack Overflow
The float data type is a ... double data type is a double-precision 64-bit IEEE 754 floating point. What does it mean? And when should I use float instead of double or vice-versa? ... You should use floats instead of double when memory usage is critical. If you need more precise computations, use doubles. ... @Everv0id: I'm not sure of any situation in which memory was so tight that one had to sacrifice accuracy for space. (You're using Java, for goodness' ... More on stackoverflow.com
🌐 stackoverflow.com
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
double keyword help
You would use double in the same way as you would use float. The type double is a 64-bit floating-point data type. It stores floating-point (decimal) numbers in the space of 64 bits (eight bytes). The type float is a 32-bit floating-point data type. It stores floating-point (decimal) numbers in the space of 32 bits (four bytes). The type double has double the bits available when compared to the float type, hence the name of the type. Using a double instead of a float will increase the exactness/precision of your calculations, because when you have more bits available for storage the number of decimals stored increases. More on reddit.com
🌐 r/javahelp
14
5
April 7, 2021
[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
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?
... The key difference between a float and double in Java is that a double can represent much larger numbers than a float. Both data types represent numbers with decimals, but a float is 32 bits in size while a double is 64 bits.
Published: May 23, 2026
🌐
Software Testing Help
softwaretestinghelp.com › home › java › java double – tutorial with programming examples
Java Double - Tutorial With Programming Examples
April 1, 2025 - As we all know, Java has eight primitive types i.e. int, short, long, byte, float, double, char, and boolean. The Java double is one of the primitive data types whose width and range is more than float.
🌐
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.
Find elsewhere
🌐
Tutorialspoint
tutorialspoint.com › java › double_keyword_in_java.htm
Java - double Keyword (double Data Type)
Java Vs. C++ ... The double keyword is used to define a double-type variable that stores a double value (which is a floating-type value). The double is a primitive data type in Java.
🌐
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.
🌐
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).
🌐
Aimtocode
aimtocode.com › double-data-type-in-java.php
Double Data type In Java - Aimtocode
Variable of type double represents double precision floating point numbers and have 15 significant digits. It is a 64 bits data type. It can be ranged from 1.7e-308 to 1.7e+3.8
🌐
CodeGym
codegym.cc › java blog › java numbers › java double keyword
Java double keyword
February 19, 2025 - Float is 32 bits, of which 1 bit ... digits. The name double comes from double float. The double type is twice as large as float: 8 bytes versus 4....
🌐
javaspring
javaspring.net › blog › what-does-double-mean-in-java
Understanding the `double` Data Type in Java — javaspring.net
This blog will delve into the fundamental concepts of the double data type, its usage methods, common practices, and best practices. ... In Java, the double is a 64 - bit IEEE 754 floating-point number. It can represent a wide range of values, ...
🌐
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.
🌐
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.
🌐
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.
🌐
Oreate AI
oreateai.com › blog › understanding-the-double-data-type-in-java › 23c3335fed5cbf70f2a537664745cd6b
Understanding the Double Data Type in Java - Oreate AI Blog
December 19, 2025 - In Java, the term 'double' refers to a data type that is used for representing decimal numbers with double precision.