I was looking at a program I found online and I see that the author used DBL_MAX in a few cases. I wasn't sure what it was so I researched a little, but there was not much explaining what it is and what its used for.
Can anyone explain what it is and why you should use it?
Some examples of use in the code were:
localT.maxTemp = -DBL_MAX;
double avg = -DBL_MAX;
It is a constant defined in
float.h
or<cfloat>
. This header describes the characteristics of floating types for the specific system and compiler implemetation used.DBL_MAX
is maximum finite representable floating-point number.http://en.cppreference.com/w/cpp/types/climits
The
maximum finite representable floating-point number
.Take a look here if you find anything similar.
As it was said by others
DBL_MAX
defined in header<cfloat>
in C++ or<float.h>
in C is the value of maximum representable finite floating-point (double) numberIn C++ you can get the same value using class
std::numeric_limits
defined in header<limits>
Here is an example of using the both approaches
At www.ideone.com (on-line C++ compiler) the output is