limits header provides the template methods that can be called to obtain the maximum and minimum values of any numeric type in C++. For example,
max() returns the maximum value. For
int, this is equivalent to obtaining the value of
INT_MAX in C.
min() returns the minimum value. Note that for
double, this returns the smallest positive value for that type.
DBL_MIN return the same in C. This is necessary in many programs where you might want to know the smallest granularity of the
However, in most applications using
double, you actually want to know the lowest value, such that there is no other value in this type that is lesser. This is typically needed to assign a starting value when looking for the biggest value in some sequence.
Thankfully, C++11 now has
lowest() that can be used for this. This is equivalent to
Tried with: GCC 4.9.2 and Ubuntu 14.04