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 )
October 20, 2025 - Java™ Platform Standard Ed. 8 ... The Double class wraps a value of the primitive type double in an object.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-number-doublevalue-method
Java Number.doubleValue() Method - GeeksforGeeks
May 15, 2025 - The double data type can hold fractional values, so, it is useful for converting integer-based values when working with mixed-type arithmetic expressions. Example 1: In this example, we are going to convert Integer and Float into double using ...
Discussions

floating point - What exactly does Double mean in java? - Stack Overflow
Even many work in Java has the same question.Cheers. ... The Double class wraps a value of the primitive type double in an object. More on stackoverflow.com
🌐 stackoverflow.com
Maximum value of a double
According to the LR the maximum value of a double is: Numerical limits The maximum value of a Double is: ±1.79769313486231570814527423731704357e+308 The minimum value towards zero is: ±4.94065645841246544176568792868221372e-324 So, what am I doing wrong in this example since what I get is ... More on forum.xojo.com
🌐 forum.xojo.com
0
May 4, 2021
Will Double.parseDouble always return the same exact value?
http://docs.oracle.com/javase/7/docs/api/java/lang/Double.html#valueOf(java.lang.String) It appears so. First, the string is converted to an imaginary "infinitely precise" representation, and then rounded via the IEEE floating point specification to a double. That sounds like a pretty deterministic algorithm to me. More on reddit.com
🌐 r/java
10
11
September 21, 2014
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
🌐
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....
🌐
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. It is used to store decimal numbers with a higher degree of precision compared to the float data type. The double data type is commonly used in situations that require a large ...
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 - The default value and size of double is 0.0d and 8 bytes respectively. Note − This conversion may involve rounding or truncation of the given number. Following is the syntax for Java Number doubleValue() method
🌐
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?
Assign a value within the range of a float. ... When Java encounters a decimal in a program, or a calculation generates a floating point number, Java treats the number as a double.
Find elsewhere
🌐
MIT
web.mit.edu › java_v1.0.2 › www › javadoc › java.lang.Double.html
Class java.lang.Double
Returns a hashcode for this Double. ... Returns the integer value of this Double (by casting to an int).
🌐
GeeksforGeeks
geeksforgeeks.org › java › integer-doublevalue-method-in-java
Integer doubleValue() Method in Java - GeeksforGeeks
July 7, 2018 - The doubleValue() method of Integer class of java.lang package is used to convert the value of the given Integer to a Double type after a widening primitive conversion and returns it.
🌐
Xojo Programming Forum
forum.xojo.com › general
Maximum value of a double - General - Xojo Programming Forum
May 4, 2021 - According to the LR the maximum value of a double is: Numerical limits The maximum value of a Double is: ±1.79769313486231570814527423731704357e+308 The minimum value towards zero is: ±4.94065645841246544176568792868221372e-324 So, what am ...
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › java.lang.double.valueof
Double.ValueOf Method (Java.Lang) | Microsoft Learn
where Sign, FloatingPointLiteral, HexNumeral, HexDigits, SignedInteger and FloatTypeSuffix are as defined in the lexical structure sections of <cite>The Java Language Specification</cite>, 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.
🌐
Baeldung
baeldung.com › home › java › java numbers › check if a double is an integer in java
Check if a double Is an Integer in Java | Baeldung
January 25, 2024 - In this test, we assign 2.0D * Integer.MAX_VALUE to the double d3. Obviously, this value is a mathematical integer but out of Java’s integer range.
🌐
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).
🌐
Baeldung
baeldung.com › home › java › java string › convert string to double in java
Convert String to Double in Java | Baeldung
January 8, 2024 - In this tutorial, we’ll cover many ways of converting a String into a double in Java. We can convert a String to a double using the Double.parseDouble method: assertEquals(1.23, Double.parseDouble("1.23"), 0.000001); Similarly, we can convert a String into a boxed Double using the Double.valueOf method:
🌐
TheServerSide
theserverside.com › blog › Coffee-Talk-Java-News-Stories-and-Opinions › Java-double-precision-2-decimal-places-example-float-range-math-jvm
Java double decimal precision
The precision of a double in Java is 10-324 decimal places, although true mathematical precision can suffer due to issues with binary arithmetic.
🌐
Oracle
docs.oracle.com › en › java › javase › 24 › docs › api › java.base › java › lang › Double.html
Double (Java SE 24 & JDK 24)
July 15, 2025 - 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.
🌐
Vultr Docs
docs.vultr.com › java › examples › convert-string-variables-to-double
Java Program to convert string variables to double | Vultr Docs
December 20, 2024 - This snippet correctly converts the string "1.234,56", which is formatted according to typical European conventions, to the double value 1234.56. The DecimalFormat takes care of handling the comma as a decimal separator. Converting string variables to double in Java can be handled in multiple ways depending on the specific requirements of your application.
🌐
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 - Then, because you're trying to add the two Double objects with the + operator, the compiler probably generates bytecode to invoke d2.doubleValue() to unbox it to perform the addition using primitive double values. Since d2 is null, you get the NullPointerException. ... 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()
🌐
CodeGym
codegym.cc › java blog › java numbers › java double keyword
Java double keyword
February 19, 2025 - Let's give some examples of using the Java double keyword to create a variable. double myPrice = 5.0; double height = 180; double x = 7.1, y = 3.0; Here in the variable myPrice we have the value 5.0, in the variable height — 180, in x we put ...