DBL_MAX is defined in <float.h>. Its availability in <limits.h> on unix is what is marked as "(LEGACY)".

(linking to the unix standard even though you have no unix tag since that's probably where you found the "LEGACY" notation, but much of what is shown there for float.h is also in the C standard back to C89)

Answer from Random832 on Stack Overflow
🌐
DaniWeb
daniweb.com › programming › software-development › threads › 463134 › what-is-the-max-value-of-a-double
c++ - What is the Max value of a double? [SOLVED] | DaniWeb
September 13, 2013 - All I did in that code was replace a line of code by an abstract function call, it was just to make you think about it at an abstract level, instead of … — mike_2000_17 2,669 Jump to Post ... I think it is 1.79769e+308. ... If you then output a statement for this limit for type double, it should give the number I gave up top. ... It tells me not to use short.MaxValue so I assumed that numeric_limits::max will do the same as this?
Discussions

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
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
Is the maximum supported digits for a double type in c is 15 digits or more
Due to the precision limitation ... or approximation occurs on output, causing the last digit to become 8 instead of the original 7. ... A double is stored in base 2 not decimal. It’s stored in 64 bits. The mantissa is 52 bits, or max 179769313486232 in decimal... More on learn.microsoft.com
🌐 learn.microsoft.com
2
0
May 28, 2023
float and double - C++ Forum
I understood that integer can have numbers from 0 to 65536. but didn't understand the limitations of the float and double. ... Minimum value for a float is 1.175494351 E – 38 (if you're not familiar with "E" it means "*10^"). Max float is 3.402823466 E + 38. More on cplusplus.com
🌐 cplusplus.com
October 31, 2012
🌐
cppreference.com
en.cppreference.com › cpp › types › numeric_limits › max
std::numeric_limits<T>::max - cppreference.com
bool: 1 = 0x1 short: 32767 = 0x7fff int: 2147483647 = 0x7fffffff long: 9223372036854775807 = 0x7fffffffffffffff unsigned long: 18446744073709551615 = 0xffffffffffffffff char: 127 = 0x7f char16_t: 65535 = 0xffff wchar_t: 2147483647 = 0x7fffffff float: 3.40282e+38 = 0x1.fffffep+127 double: 1.79769e+308 = 0x1.fffffffffffffp+1023 long double: 1.18973e+4932 = 0xf.fffffffffffffffp+16380
🌐
Reddit
reddit.com › r/c_programming › confused about the max limit we can store for float and double
r/C_Programming on Reddit: confused about the max limit we can store for float and double
February 1, 2024 -

Just started learning C. so forigve me if this is a dumb question.

For int and long, the maximum number we can assign them is 2^32 and 2^64 respectively. how about for float and double? I know that double has higher precision of about 15 decimal points while float is 7.

i also know that float is 32 bit while double is 64 bit. So does that mean the highest we can store them (2^32)and (2^64) but with decimal points in between their numbers? i aslo learnt that these data type cant have unsigned value so does that value doubles?

🌐
Quora
quora.com › What-are-the-maximum-and-minimum-value-of-double-float-variables-in-C
What are the maximum and minimum value of double float variables in C++? - Quora
Answer: In C++ you can find the answer to your question n the header files. Some of the limits are dependent on implementation which means the standard doesn’t say what the values are. You have to look them up ni a header file: climits for integral types cfloat for floating point types. https:...
🌐
O'Reilly
oreilly.com › library › view › c-cookbook › 0596007612 › ch03s08.html
3.7. Getting the Minimum and Maximum Values for a Numeric Type - C++ Cookbook [Book]
November 8, 2005 - Here’s what I get on Windows XP using Visual C++ 7.1: short: min: -32768 max: 32767 int: min: -2147483648 max: 2147483647 long: min: -2147483648 max: 2147483647 float: min: 1.17549e-038 max: 3.40282e+038 double: min: 2.22507e-308 max: 1.79769e+308 ...
Authors: D. Ryan StephensChristopher DigginsJonathan TurkanisJeff Cogswell
Published: 2005
Pages: 594
🌐
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…
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › c++ › stdnumeric_limitsmax-and-stdnumeric_limitsmin-in-c
std::numeric_limits::max() and std::numeric_limits::min() in C++ - GeeksforGeeks
July 23, 2025 - // C++ program to illustrate the // function numeric_limits<T>::max #include <iostream> #include <limits> using namespace std; // Driver Code int main() { cout << "bool: " << numeric_limits<bool>::max() << '\n'; // It returns 127 in ASCII value // to print in integer that can // be typecast it to int() cout << "char: " << int(numeric_limits<char>::max()) << '\n'; cout << "unsigned char: " << int(numeric_limits<unsigned char>::max()) << '\n'; cout << "short: " << numeric_limits<short>::max() << '\n'; cout << "int: " << numeric_limits<int>::max() << '\n'; cout << "unsigned int: " << numeric_limits<unsigned int>::max() << '\n'; cout << "long long: " << numeric_limits<long long>::max() << '\n'; cout << "float: " << numeric_limits<float>::max() << '\n'; cout << "double: " << numeric_limits<double>::max() << '\n'; cout << "size_t: " << numeric_limits<size_t>::max() << '\n'; }
Top answer
1 of 2
1

Hi Debojit Acharjee,

The significand of the double type is approximately 15 to 17 decimal digits for most platforms. In most cases, a variable of type double can accurately represent 15 to 17 decimal digits. Numbers outside this range may lose precision or be rounded.

When I defined a 18 digits number, the result lost precision.

When using floating-point numbers, you should choose the appropriate data type according to your specific needs and precision requirements, and avoid using values beyond its representation range for calculations.

Regarding the double type, this documentation states:

Microsoft Specific The double type contains 64 bits: 1 for sign, 11 for the exponent, and 52 for the mantissa. Its range is +/-1.7E308 with at least 15 digits of precision.

You could also refer to this document for the float type.

Best regards,

Elya Yao


If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

2 of 2
0

A double is stored in base 2 not decimal. It’s stored in 64 bits. The mantissa is 52 bits, or max 179769313486232 in decimal. The exponent is 11 bits or max of 2047 in decimal. The final bit is the sign bit.

See:

https://en.wikipedia.org/wiki/Computer_number_format#:~:text=an%2011%2Dbit%20binary%20exponent,gives%20the%20actual%20signed%20value

🌐
The C Book
publications.gbdirect.co.uk › c_book › chapter9 › limits.html
The C Book — Limits
Table 9.1 gives the names declared, the allowable values, and a comment on what they mean. For example, the description of SHRT_MIN shows that in a given implementation the value must be less than or equal to −32767: this means that for maximum portability a program cannot rely on short variables ...
🌐
Cplusplus
cplusplus.com › forum › beginner › 83526
float and double - C++ Forum
October 31, 2012 - Min double is 2.2250738585072014 E – 308 and max double is 1.7976931348623158 E + 308. If you're not understanding these limitations, keep in mind that the computer is storing them in binary. The number and all the decimal places take up a certain amount of memory in binary.
🌐
Reddit
reddit.com › r/cpp_questions › why don't float/double have a max & min value like 'int' or 'char'?
r/cpp_questions on Reddit: Why don't float/double have a max & min value like 'int' or 'char'?
July 17, 2023 -

source: https://www.tutorialspoint.com/cplusplus/cpp_data_types.htm#

There's no data shown for the limits floats and doubles have.

However, 'int' is -2147483648 to 2147483647 and 'char' is 0 to 255

🌐
Cmu
jitsi.cmu.edu.jm › home › c++: double max value trick & pitfalls
C++: Double Max Value Trick & Pitfalls
March 16, 2025 - The largest representable positive ... resulting in overflow. This value can be accessed through the `std::numeric_limits::max()` function in the “ header....
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › system.double.maxvalue
Double.MaxValue Field (System) | Microsoft Learn
You can try changing directories. ... Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here. Represents the largest possible value of a Double.
🌐
GameDev.net
gamedev.net › home › forums › for beginners › max value for double ?
max value for DOUBLE ? - GameDev.net Forums
May 10, 2006 - I believe what you are looking for is this. It lists the minimum and maximum values a double can hold in C++ as -1.7*10^308 and 1.7*10^308, respectively.
Top answer
1 of 4
26

Alright. Using what I learned from here (thanks everyone) and the other parts of the web I wrote a neat little summary of the two just in case I run into another issue like this.

In C++ there are two ways to represent/store decimal values.

Floats and Doubles

A float can store values from:

  • -340282346638528859811704183484516925440.0000000000000000 Float lowest
  • 340282346638528859811704183484516925440.0000000000000000 Float max

A double can store values from:

  • -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0000000000000000 Double lowest

  • 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0000000000000000 Double max

Float's precision allows it to store a value of up to 9 digits (7 real digits, +2 from decimal to binary conversion)

Double, like the name suggests can store twice as much precision as a float. It can store up to 17 digits. (15 real digits, +2 from decimal to binary conversion)

e.g.

     float x = 1.426;
     double y = 8.739437;

Decimals & Math

Due to a float being able to carry 7 real decimals, and a double being able to carry 15 real decimals, to print them out when performing calculations a proper method must be used.

e.g

include

typedef std::numeric_limits<double> dbl; 
cout.precision(dbl::max_digits10-2); // sets the precision to the *proper* amount of digits.
cout << dbl::max_digits10 <<endl; // prints 17.
double x = 12345678.312; 
double a = 12345678.244; 
// these calculations won't perform correctly be printed correctly without setting the precision.


cout << endl << x+a <<endl;

example 2:

typedef std::numeric_limits< float> flt;
cout.precision(flt::max_digits10-2);
cout << flt::max_digits10 <<endl;
float x =  54.122111;
float a =  11.323111;

cout << endl << x+a <<endl; /* without setting precison this outputs a different value, as well as making sure we're *limited* to 7 digits. If we were to enter another digit before the decimal point, the digits on the right would be one less, as there can only be 7. Doubles work in the same way */

Roughly how accurate is this description? Can it be used as a standard when confused?

2 of 4
15

The std::numerics_limits class in the <limits> header provides information about the characteristics of numeric types.

For a floating-point type T, here are the greatest and least values representable in the type, in various senses of “greatest” and “least.” I also include the values for the common IEEE 754 64-bit binary type, which is called double in this answer. These are in decreasing order:

  • std::numeric_limits<T>::infinity() is the largest representable value, if T supports infinity. It is, of course, infinity. Whether the type T supports infinity is indicated by std::numeric_limits<T>::has_infinity.

  • std::numeric_limits<T>::max() is the largest finite value. For double, this is 21024−2971, approximately 1.79769•10308.

  • std::numeric_limits<T>::min() is the smallest positive normal value. Floating-point formats often have an interval where the exponent cannot get any smaller, but the significand (fraction portion of the number) is allowed to get smaller until it reaches zero. This comes at the expense of precision but has some desirable mathematical-computing properties. min() is the point where this precision loss starts. For double, this is 2−1022, approximately 2.22507•10−308.

  • std::numeric_limits<T>::denorm_min() is the smallest positive value. In types which have subnormal values, it is subnormal. Otherwise, it equals std::numeric_limits<T>::min(). For double, this is 2−1074, approximately 4.94066•10−324.

  • std::numeric_limits<T>::lowest() is the least finite value. It is usually a negative number large in magnitude. For double, this is −(21024−2971), approximately −1.79769•10308.

  • If std::numeric_limits<T>::has_infinity and std::numeric_limits<T>::is_signed are true, then -std::numeric_limits<T>::infinity() is the least value. It is, of course, negative infinity.

Another characteristic you may be interested in is:

  • std::numeric_limits<T>::digits10 is the greatest number of decimal digits such that converting any decimal number with that many digits to T and then converting back to the same number of decimal digits will yield the original number. For double, this is 15.
🌐
Dirask
dirask.com › posts › C-minimum-and-maximum-double-value-pYemwp
C++ - minimum and maximum double value
#include <limits> #include <iostream> using namespace std; int main() { double min = numeric_limits<double>::min(); // minimum positive value double max = numeric_limits<double>::max(); // maximum positive value double lowest = std::numeric...
🌐
Educative
educative.io › answers › what-is-the-doublemaxvalue-in-c-sharp
What is the Double.MaxValue in C#?
The Double.MaxValue in C# is a Double field that represents the largest possible value of Double. It is constant and read-only.
🌐
Cplusplus
cplusplus.com › reference › limits › numeric_limits
std::numeric_limits
Provides information about the properties of arithmetic types (either integral or floating-point) in the specific platform for which the library compiles. This class template is specialized for every fundamental arithmetic type, with its members describing the properties of type T. This template ...