Double.MAX_VALUE is the maximum value a double can represent (somewhere around 1.7*10^308).

This should end in some calculation problems, if you try to subtract the maximum possible value of a data type.

Even though when you are dealing with money you should never use floating point values especially while rounding this can cause problems (you will either have to much or less money in your system then).

Answer from Kuchi on Stack Overflow
Top answer
1 of 3
45

Double.MAX_VALUE is the maximum value a double can represent (somewhere around 1.7*10^308).

This should end in some calculation problems, if you try to subtract the maximum possible value of a data type.

Even though when you are dealing with money you should never use floating point values especially while rounding this can cause problems (you will either have to much or less money in your system then).

2 of 3
16

Resurrecting the dead here, but just in case someone stumbles against this like myself. I know where to get the maximum value of a double, the (more) interesting part was to how did they get to that number.

double has 64 bits. The first one is reserved for the sign.

Next 11 represent the exponent (that is 1023 biased). It's just another way to represent the positive/negative values. If there are 11 bits then the max value is 1023.

Then there are 52 bits that hold the mantissa.

This is easily computed like this for example:

public static void main(String[] args) {

    String test = Strings.repeat("1", 52);

    double first = 0.5;
    double result = 0.0;
    for (char c : test.toCharArray()) {
        result += first;
        first = first / 2;
    }

    System.out.println(result); // close approximation of 1
    System.out.println(Math.pow(2, 1023) * (1 + result));
    System.out.println(Double.MAX_VALUE);

} 

You can also prove this in reverse order :

    String max = "0" + Long.toBinaryString(Double.doubleToLongBits(Double.MAX_VALUE));

    String sign = max.substring(0, 1);
    String exponent = max.substring(1, 12); // 11111111110
    String mantissa = max.substring(12, 64);

    System.out.println(sign); // 0 - positive
    System.out.println(exponent); // 2046 - 1023 = 1023
    System.out.println(mantissa); // 0.99999...8
🌐
Delft Stack
delftstack.com › home › howto › java › double max value in java
How to Double max value in Java | Delft Stack
February 14, 2024 - Here, maxValue is a variable of type double, and it is assigned the maximum finite value that can be represented by a double. In Java, Double.MAX_VALUE is a constant representing the maximum finite positive value that can be represented by the double data type.
Discussions

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
18
0
May 4, 2021
How would you set a double equal to its max value?
https://docs.oracle.com/javase/7/docs/api/java/lang/Double.html e: To further clarify since you mention c++. Java has two double types, one which is a simple data type ex: double d and one which is an object which wraps the double adding functions to it ex: Double d The documentation I provided above shows methods and fields available on the Double object. Since the field you need is a static field all you need to do is something like: double myDouble = Double.MAX_VALUE More on reddit.com
🌐 r/javahelp
2
7
September 21, 2016
confused about the max limit we can store for float and double
Interestingly, a double can exactly represent any integer up to about 2^53. Here's more info on the max limits: https://en.wikipedia.org/wiki/IEEE_754 More on reddit.com
🌐 r/C_Programming
8
3
February 1, 2024
Which is larger? Long vs Double
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. 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/javahelp
10
3
January 19, 2023
🌐
Coderanch
coderanch.com › t › 670713 › java › Double-MAX
What is Double.MAX_VALUE + 1? [Solved] (Java in General forum at Coderanch)
September 22, 2016 - Multiplication by the slightly larger value will cause an overflow irrespective of how many additional bits are used in the intermediate representation, because the result of the calculation will be reduced to 64 bits. Use the javap tool to see what is happening:-The value of X is shown at number 5.
🌐
MIT
web.mit.edu › java_v1.0.2 › www › javadoc › java.lang.Double.html
Class java.lang.Double
The greatest maximum value that a double can have is 1.79769313486231570e+308d. MIN_VALUE ... The minimum value a double can have. The lowest minimum value that a double can have is 2.2250738585072014E-308. ... Constructs a Double wrapper for the specified double value.
🌐
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.94065645841246544176568792868…
🌐
Tutorialspoint
tutorialspoint.com › java › lang › math_max_double.htm
Java - Math max(double x, double y) Method
The following example shows the usage of Math max() method of a positive and a negative value. package com.tutorialspoint; public class MathDemo { public static void main(String[] args) { // get two double numbers double x = -60984.1; double y = 497.99; // call max and print the result System.out.println("Math.max(" + x + "," + y + ")=" + Math.max(x, y)); } }
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-guava-doubles-max-method-with-examples
Java Guava | Doubles.max() method with Examples - GeeksforGeeks
July 11, 2025 - Doubles.max() is a method of Doubles Class in Guava library which is used to find the greatest value present in an array. The value returned by this method is the largest double value in the specified array.
🌐
Javatpoint
javatpoint.com › java-double-max-method
Java Double max() Method - Javatpoint
The max() method of Java Double class returns the double object having greater value amongst two double values. The result returned is same as by invoking Math.max() method.
Find elsewhere
🌐
LabEx
labex.io › tutorials › java-java-double-max-method-117623
Mastering the Java Double Max Method | LabEx
Java max() method is a built-in method that is available in the Double class of the java.lang package in Java. This method is used to return the numerically greater value(maximum value) of the two numbers passed as arguments.
🌐
Programming.Guide
programming.guide › java › double-range.html
Java: Range of a double | Programming.Guide
In Java, a double is a 64-bit IEEE 754 floating point. Double values are symmetrical around origo and has a maximum magnitude of 1.7976931348623157e308
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › java.lang.double.maxvalue
Double.MaxValue Field (Java.Lang) | Microsoft Learn
A constant holding the largest positive finite value of type double, (2-2<sup>-52</sup>)&middot;2<sup>1023</sup>. [Android.Runtime.Register("MAX_VALUE")] public const double MaxValue = 1.7976931348623157E+308;
🌐
javaspring
javaspring.net › blog › java-double-max-value
Java Double Max Value: A Comprehensive Guide — javaspring.net
Negative values can range from -Double.MAX_VALUE to -Double.MIN_VALUE. Understanding these limits is essential when working with numerical data to avoid unexpected results. In Java, you can access the maximum value of the double data type using the Double.MAX_VALUE constant.
🌐
Simplesolution
simplesolution.dev › java-get-maximum-double-value
Java Get Maximum Double Value - Simple Solution
In Java, to get the maximum double value we can use the Double.MAX_VALUE constant as the following example Java program.
🌐
javaspring
javaspring.net › blog › max-value-of-double-in-java
Understanding the Maximum Value of `double` in Java — javaspring.net
This standard allocates 64 bits to represent a double value, where 1 bit is used for the sign, 11 bits for the exponent, and 52 bits for the significand (also known as the mantissa).
🌐
Oracle
docs.oracle.com › javase › 7 › docs › api › java › lang › Double.html
Double (Java Platform SE 7 )
Otherwise, s is regarded as ... 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. Note that the round-to-nearest rule also implies overflow and underflow behaviour; if the exact value of s is large enough in magnitude (greater than or equal to (MAX_VALUE + ...
🌐
Java Guides
javaguides.net › 2024 › 06 › java-double-max-and-min-methods.html
Java Double max() and min() Methods
June 17, 2024 - The Double.max() and Double.min() methods in Java are used to return the greater or smaller of two double values, respectively.
🌐
Beyondgrader
beyondgrader.com › java › max-double › challen@illinois.edu › 2020.10.0
Max Double (Java) - Go Beyond Grading
Define a public class named Max which stores the maximum from a series of provided double values. Max should define a single public constructor that accepts a double that sets the initial value.
🌐
Tutorialspoint
tutorialspoint.com › java › number_max.htm
Java - max() Method
double max(double arg1, double arg2) float max(float arg1, float arg2) int max(int arg1, int arg2) long max(long arg1, long arg2) ... This method accepts any primitive data type as a parameter.
🌐
Vultr Docs
docs.vultr.com › java › standard library › java › lang › math › max()
Java Math max() - Find Maximum Value
December 3, 2024 - Consider scenarios that involve special floating-point values like NaN. Apply Math.max() to see how it behaves with NaN. ... double n1 = Double.NaN; double n2 = 1.0; double result = Math.max(n1, n2); System.out.println("Result with NaN: " + result);