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
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › Double.html
Double (Java Platform SE 8 )
October 20, 2025 - Returns the greater of two double values as if by calling Math.max. ... Returns the smaller of two double values as if by calling Math.min. ... Java™ Platform Standard Ed.
Discussions

Java double.MAX_VALUE? - Stack Overflow
For my assignment I have to create a Gas Meter System for a Gas company to allow employees to create new customer accounts and amend data such as name and unit costs along with taking (depositing) ... 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
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
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
🌐
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?
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:
🌐
Protocol Buffers
protobuf.dev › programming-guides › proto3
Language Guide (proto 3) | Protocol Buffers Documentation
In languages that support open enum types with values outside the range of specified symbols, such as C++ and Go, the unknown enum value is simply stored as its underlying integer representation. In languages with closed enum types such as Java, a case in the enum is used to represent an unrecognized value, and the underlying integer can be accessed with special accessors.
🌐
Quora
quora.com › What-does-double-max-double-negative_infinity-mean-in-Java
What does 'double max = double.negative_infinity' mean in Java? - Quora
Answer (1 of 5): If you happened to be looking for a less technical answer, it just means that you are setting a variable called “max” to the largest possible negative number that the computer uses. Not really infinity but close enough for most human beings.
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
🌐
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 ...
🌐
Tutorialspoint
tutorialspoint.com › home › java/lang › java math.max() method
Java - Math max(double x, double y) Method
September 1, 2008 - The Java Math max(double a, double b) returns the greater of two double values. That is, the result is the argument closer to positive infinity. If the arguments have the same value, the result is that same value.
Find elsewhere
🌐
Medium
medium.com › @AlexanderObregon › finding-the-maximum-value-between-two-inputs-in-java-855680ab9598
Finding the Max Value Between Two Inputs in Java | Medium
August 29, 2025 - Each call reduces two values to one, and chaining them together quickly finds the maximum across several numbers without introducing new syntax. Math.max behaves differently depending on the data type because integers, longs, floats, and doubles each have their own quirks. For integers and longs, the logic is always clear: the larger number is returned. No special cases are involved. For floating-point numbers, things are more complex. Java follows IEEE 754 rules for floating-point arithmetic.
🌐
Oracle
docs.oracle.com › javadb › 10.10.1.2 › ref › rrefsqljdoubleprecision.html
DOUBLE PRECISION data type
These limits are the same as the java.lang.Double Java type limits. An exception is thrown when any double value is calculated or entered that is outside of these value ranges. Arithmetic operations do not round their resulting values to zero.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-math-max-method
Java Math max() Method - GeeksforGeeks
May 14, 2025 - ... // Java program to demonstrate ... java.lang.Math; public class Geeks { public static void main(String args[]) { double a = 12.123; double b = 12.456; // prints the maximum of two numbers System.out.println(Math.max(a, b)); ...
🌐
Coderanch
coderanch.com › t › 670713 › java › Double-MAX
What is Double.MAX_VALUE + 1? [Solved] (Java in General forum at Coderanch)
September 22, 2016 - That means that no matter how small value2 becomes, as long as both operands are positive, you well never get POSITIVE_INFINITY, because MAX_VALUE is the closest approximation of the actual result. The matter is different when value2 is 0.0 or -0.0. I'm not certain if this is correct, but here's an overview of what I believe are the correct results of divisions when zero or infinity are involved: ... It shou‍ld all be in the Java® Language Specification (=JLS).
🌐
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.
🌐
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>. It is equal to the hexadecimal floating-point literal 0x1.fffffffffffffP+1023 and also equal to Double.longBitsToDouble(0x7fef...
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › system.double.maxvalue
Double.MaxValue Field (System) | Microsoft Learn
public class Temperature { public static double MinValue { get { return Double.MinValue; } } public static double MaxValue { get { return Double.MaxValue; } } // The value holder protected double m_value; public double Value { get { return m_value; } set { m_value = value; } } public double Celsius { get { return (m_value-32.0)/1.8; } set { m_value = 1.8*value+32.0; } } }
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-guava-doubles-max-method-with-examples
Java Guava | Doubles.max() method with Examples - GeeksforGeeks
July 11, 2025 - Return Value: This method returns a double value that is the maximum value in the specified array. Exceptions: The method throws IllegalArgumentException if the array is empty. Below programs illustrate the use of the above method: Example 1 ...
🌐
Wikipedia
en.wikipedia.org › wiki › Single-precision_floating-point_format
Single-precision floating-point format - Wikipedia
1 week ago - A floating-point variable can represent ... whereas an IEEE 754 32-bit base-2 floating-point variable has a maximum value of (2 − 2−23) × 2127 ≈ 3.4028235 × 1038....