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
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
🌐
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
🌐
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
🌐
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
🌐
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....
🌐
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.
Find elsewhere
🌐
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.
🌐
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:...
🌐
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 ...
🌐
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

🌐
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
🌐
Reddit
reddit.com › r/cpp › largest integer a long double can hold?
r/cpp on Reddit: Largest integer a long double can hold?
February 6, 2025 -

Alright so this might be a stupid question but i need some help. I'm learning how to write in C++ for a class that I'm taking and I need to validate the data that a user could put in. I need to make sure it can take any number (decimal or integer) but not any string or other char. If this might work, I just want to know how large of an integer can be put into a long double. My idea is to use a loop to get it work and I want to use a long double for the decision statement so that the user could input valid info if they put something wrong. If there is a better way to do this, please let me know, but I am still only learning out so I ask that you're patient with me please.

Edit: Thank you all so much for the help, I'm only 3 weeks into this course and technically should not have learned loops or if else statements yet. I'm a little confused on the answers but Ill continue to try and figure them out. What I am specifically looking for is which what is the largest form of whole number that can be stored in a float that can also use any and all numbers before it. Like if 1 million was that largest a float could hold for integers, and I want to use 999,999 or 999,998 etc. etc. I'm using code blocks for anyone wondering since I've seen comments saying that the answer might vary depending on what I'm coding on

Top answer
1 of 12
44
There are two potential answers here depending on what you want, and the size of long double can vary from platform to platform (I've seen both 64-bit and 80-bit long doubles), so here are the two options First, the absolute largest integer that a float of any kind can hold is that float's maximum (non-infinity) value (the exponent of the float is so large at that point that it's guaranteed to be an integer): std::numeric_limits::max() For a 64-bit long double this would likely be roughly 1.79769e+308, and for 80-bit it's likely 1.18973e+4932 However, there are a lot of integers from 0 to that number that are not fully representable, so what I assume you're actually asking for is "the largest integer a long double can hold while being able to represent all integers less than it" in which case the answer has to do with the number of bits in the mantissa: (1ull << std::numeric_limits::digits()) - 1 For a standard 64-bit long double this number is 9,007,199,254,740,991 (2 to the 53rd minus 1), and for an 80-bit long double it'd likely be 18,446,744,073,709,551,615 (2 to the 64th minus 1) (Edit: if you're doing this with 80-bit long doubles, the above math would technically fail because 1ull << 64 is undefined behavior, you'd want to special case check whether std::numeric_limits::digits() 64 and, if so, then your actual result is std::numeric_limits::max() (which is 264 - 1) Edit: accidentally wrote "2 to the 54th minus 1" instead of "2 to the 53rd minus 1", fixed
2 of 12
15
https://en.cppreference.com/w/cpp/types/numeric_limits
🌐
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