minimum double value in C/C++ minimum double value in C/C++ c c

minimum double value in C/C++


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


Floating point numbers (IEEE 754) are symmetrical, so if you can represent the greatest value (DBL_MAX or numeric_limits<double>::max()), just prepend a minus sign.

And then is the cool way:

double f;(*((long long*)&f))= ~(1LL<<52);


In C, use

#include <float.h>const double lowest_double = -DBL_MAX;

In C++pre-11, use

#include <limits>const double lowest_double = -std::numeric_limits<double>::max();

In C++11 and onwards, use

#include <limits>constexpr double lowest_double = std::numeric_limits<double>::lowest();