-DBL_MAX in ANSI C, which is defined in float.h.

Answer from dfa on Stack Overflow
🌐
Cplusplus
cplusplus.com › forum › general › 53760
smallest double value greater zero - C++ Forum
October 30, 2011 - now my question is: what is the difference between min() and denorm_min() and why does not my code match any of these two? i looked up the doc here, but i dont understand it. ... You're packing your int array back to front. 000000001 00000000 -> 2.122e-314 000000000 00000001 -> 4.94066e-324 swapping your code to 1 and then 0, rather than vice versa... should do the trick! Andy Double precision floating-point format http://en.wikipedia.org/wiki/Double_precision Endianness http://en.wikipedia.org/wiki/Endianness
Discussions

c - Minimum of two floating-point numbers - Code Review Stack Exchange
I'm learning C and I just had the exercise to write a function that checks for the lower one of two floating-points. So I thought, I either could use pointer and also return the pointer of the lower value - otherwise, I simply could use the values and return the lower value. double* pointer_min_v... More on codereview.stackexchange.com
🌐 codereview.stackexchange.com
September 2, 2021
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
variables - What are the actual min/max values for float and double (C++) - Stack Overflow
It is, of course, infinity. Whether the type T supports infinity is indicated by std::numeric_limits::has_infinity. std::numeric_limits::max() is the largest finite value. For double, this is 21024−2971, approximately 1.79769•10308. std::numeric_limits::min() is the smallest positive ... More on stackoverflow.com
🌐 stackoverflow.com
float and double - C++ Forum
what are the valid values of float and double? 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^"). More on cplusplus.com
🌐 cplusplus.com
October 31, 2012
🌐
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:...
Top answer
1 of 4
16

Versatility

The pointer version is less versatile.

If the two values come from expressions like in min_value(x + 13, 2 * y), you can't use the pointer version, as neither x + 13 nor 2 * y exist as pointable memory locations, only as temporary values.

Surprises

The pointer version might give surprising results in the long run.

If now first is lower than second, the function will return a pointer to first. If you later change the content of the first variable, the value of the result changes as well.

If first and second are local variables declared inside a function foo(), and you happen to return the pointer_min_value() result (the pointer), then, after leaving foo(), the variables no longer exist, and your result points to garbage memory.

2 of 4
10

Some beautifying

I think first < second ? first : second is a tiny bit more readable. First comes first.

Double problems

Floating points are tricky. What will happen if one of doubles will be NaN? Of course, you can always say that the function assumes both values are valid, but you should consider this too.

Pointer problems

Pointers are also tricky. pointer_min_value(NULL, NULL) will cause UB. Once again, adding a comment "no NULLs allowed" is ok - but neglecting this possibility isn't.

Making sure the values, passed by pointers, won't change

You can add const modifier to arguments and returning value to do this, if you mean this.

Performance considerations

Passing a huge argument by value can be a bad idea; but doubles are only 8 bytes - like pointers on 86x64 architecture; pointers on 86x32 are 4 bytes, so you can save 8 bytes of stack space with pointer_min_value. But who cares with modern RAM sizes?

On the other hand, dereferencing pointers isn't free, so calc_min_value will be a bit faster, but who cares with modern CPU/RAM speeds and cache sizes?

Chief difference

The only thing pointer_min_value does that calc_min_value doesn't - it returns a pointer. Why is this important? Because you can change the returned value!

*pointer_min_value(&first, &second) = 0.0;

changes lesser one to 0.0. That's the greatest difference.

🌐
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...
🌐
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
🌐
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 - bool: 1 char: 127 unsigned char: ... size_t: 18446744073709551615 · The std::numeric_limits<T>::min() function is used to get the minimum finite value representable by the numeric type T....
🌐
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

Find elsewhere
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.
🌐
cppreference.com
en.cppreference.com › cpp › types › numeric_limits › min
std::numeric_limits<T>::min - cppreference.com
bool ( 1 bytes): 0 char ( 1 bytes): ... 0x8000000000000000 std::size_t ( 8 bytes): 0 float ( 4 bytes): 1.17549e-38 or 0x1p-126 double ( 8 bytes): 2.22507e-308 or 0x1p-1022 long double (16 bytes): 3.3621e-4932 or 0x8p-16385...
🌐
The C Book
publications.gbdirect.co.uk › c_book › chapter9 › limits.html
The C Book — Limits
Implementations may choose to support values which are more negative but must provide support for at least −32767. Table 9.1. <limits.h> For floating point numbers, the file <float.h> contains a similar set of minimum values.
🌐
Medium
medium.com › @pauljlucas › a-generic-min-function-in-c-9706edb594ad
A Generic min Function in C. Introduction | by Paul J. Lucas | Medium
July 5, 2026 - You could use min_ld to handle both float and double, but long double is typically less performant than either, so casting all floating point values to long double isn’t a good idea.
🌐
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.
🌐
Cplusplus
cplusplus.com › reference › algorithm › min
std::min
Binary function that accepts two values of type T as arguments, and returns a value convertible to bool. The value returned indicates whether the element passed as first argument is considered less than the second. The function shall not modify any of its arguments.
🌐
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.
🌐
John D. Cook
johndcook.com › blog › 2010 › 06 › 08 › c-math-gotchas
C# math gotchas
May 19, 2024 - The constant double.MaxValue in C# looks like the constant DBL_MAX in C, and indeed it is. Both give the maximum finite value of a double, which is on the order of 10^308. This might lead you to believe that double.MinValue in C# is the same as DBL_MIN in C or that double.Epsilon in C# is the ...
🌐
Apache
db.apache.org › derby › docs › 10.1 › ref › rrefsqljdoubleprecision.html
DOUBLE PRECISION
The DOUBLE PRECISION data type provides 8-byte storage for numbers using IEEE floating-point notation.
🌐
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?

🌐
Bnikolic
bnikolic.co.uk › blog › cpp-rr-epsilon
RR: Small numerical values in C++ - Bojan Nikolic
This is the value if a small perturbation to a number is necessary, e.g., f(x+std::numeric_limits<double>::epsilon())-f(x) For double precision floating point representation, these two numbers are as follows: std::numeric_limits<double>::min() 2.22507e-308 is 0:0x100000 std::numeric_limits<double>::epsilon() 2.22045e-16 is 0:0x3cb00000