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 - For example, if you do samples[i] / std::numeric_limits<double>::max(), then it won't really matter much what the value of samples[i] is, unless it is extremely close to the maximum value. What you'll get is just a number extremely close to zero, within the number of significant digits.
Discussions

max value for DOUBLE ? - GameDev.net Forums
I have searched the web a bit but cant seem to find where in the standard set of libraries to find a declaration for the max value for the double … More on gamedev.net
🌐 gamedev.net
May 10, 2006
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
Why don't float/double have a max & min value like 'int' or 'char'?
Dont use tutorials point. Its bad: reason www.learncpp.com is the best free tutorial out there. It covers everything from the absolute basics to advanced topics. It follows modern and best practice guidelines. www.cppreference.com is the best language reference out there. Stay away from cplusplus.com ( reason ), w3schools ( reason ), geeks-for-geeks ( reason ) Programiz( reason ) Tutorialspoint (), educba.com ( reason ) and thinkcpp ( reason ) Most youtube tutorials are of low quality, I would recommend to stay away from them as well. A notable exception are the CppCon Back to Basics videos. They are good, topic oriented and in depth explanations. However, they assume that you have some knowledge languages basic features and syntax and as such arent a good entry point into the language. As a tutorial www.learncpp.com is just better than any other resource. Written by u/IyeOnline . This may get updates over time if something changes or I write more scathing reviews of other tutorials :) . Feel free to copy this macro, but please copy it with this footer and the link to the original. https://www.reddit.com/user/IyeOnline/comments/10a34s2/the_c_learning_suggestion_macro/ More on reddit.com
🌐 r/cpp_questions
12
8
July 17, 2023
max value for DOUBLE ? - GameDev.net Forums
I have searched the web a bit but cant seem to find where in the standard set of libraries to find a declaration for the max value for the double … More on gamedev.net
🌐 gamedev.net
May 10, 2006
🌐
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 - 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 long double: min: 2.22507e-308 max: 1.79769e+308 ...
Authors: D. Ryan StephensChristopher DigginsJonathan TurkanisJeff Cogswell
Published: 2005
Pages: 594
🌐
Dirask
dirask.com › posts › C-minimum-and-maximum-double-value-pYemwp
C++ - minimum and maximum double value
// #include <limits> double min = std::numeric_limits<double>::min(); // minimum positive value double max = std::numeric_limits<double>::max(); // maximum positive value double lowest = std::numeric_limits<double>::lowest(); // minimum negative value
🌐
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:...
🌐
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.
🌐
cppreference.com
en.cppreference.com › cpp › types › numeric_limits › max
std::numeric_limits<T>::max - cppreference.com
#include <boost/type_index.hpp> #include <cstddef> #include <iomanip> #include <iostream> #include <limits> #include <type_traits> template<typename T> void print_max_value_of() { constexpr T max{std::numeric_limits<T>::max()}; std::cout << std::setw(16) << boost::typeindex::type_id<T>() << ": "; if constexpr (std::is_floating_point_v<T>) std::cout << std::defaultfloat << max << " = " << std::hexfloat << max << '\n'; else { constexpr auto m{static_cast<unsigned long long>(max)}; std::cout << std::dec << m << " = " << std::hex << m << '\n'; } } int main() { std::cout << std::showbase; print_max
🌐
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 ... this data type without resulting in overflow. This value can be accessed through the `std::numeric_limits::max()` function in the “ header....
Find elsewhere
🌐
Vultr Docs
docs.vultr.com › c++ › standard library › cmath › fmax()
C++ cmath fmax() - Find Maximum Value
November 11, 2024 - The fmax() function is straightforward to use but understanding its behavior with different types of inputs is essential for proper implementation. Include the <cmath> header in your C++ code, as fmax() is part of this library.
🌐
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?

🌐
CPP Scripts
cppscripts.com › cpp-max-double
Understanding C++ Max Double for Precision Calculations
November 17, 2024 - Understanding C++ Double: A Quick Guide to Precision · The maximum value a double can hold is defined in the C++ Standard Library as `DBL_MAX`. This constant represents the largest finite value that a double-type variable can store, helping developers avoid errors from exceeding limits during computation.
🌐
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

🌐
cppreference.com
en.cppreference.com › cpp › types › numeric_limits › infinity
std::numeric_limits<T>::infinity - cppreference.com
In IEEE 754, the most common binary representation of floating-point numbers, the positive infinity is the value with all bits of the exponent set and all bits of the fraction cleared. ... #include <iostream> #include <limits> int main() { double max = std::numeric_limits<double>::max(); double ...
🌐
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_limi
🌐
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 ...
🌐
GameDev.net
gamedev.net › home › forums › for beginners › max value for double ?
max value for DOUBLE ? - For Beginners - Forums - GameDev.net
May 10, 2006 - EDIT: sorry, Boder was faster ;) The values you are looking for are defined in float.h (float/double types) and limits.h (integer types). Just include them and use the constants, instead of hardcoding into your app. Here's a snippet from float.h: #define DBL_DIG 15 /* # of decimal digits of precision */ #define DBL_EPSILON 2.2204460492503131e-016 /* smallest such that 1.0+DBL_EPSILON != 1.0 */ #define DBL_MANT_DIG 53 /* # of bits in mantissa */ #define DBL_MAX 1.7976931348623158e+308 /* max value */ #define DBL_MAX_10_EXP 308 /* max decimal exponent */ #define DBL_MAX_EXP 1024 /* max binary ex
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.