1. Question:
I have a question about the DBL_MAX
and DBL_MIN
definition in Linux with gcc v4.8.5.
They are defined in limit.h
as:
#define DBL_MAX __DBL_MAX__
#define DBL_MIN __DBL_MIN__
where __DBL_MIN__
and __DBL_MAX__
are compiler specific and can be obtained by:
$ gcc -dM -E - < /dev/null
...
#define __DBL_MAX__ ((double)1.79769313486231570815e+308L)
#define __DBL_MIN__ ((double)2.22507385850720138309e-308L)
...
My question is:
Why are the values defined as long double
with suffix L
and then casted back to a double
?
2. Question:
Why is the __DBL_MIN_10_EXP__
defined with -307
but the minimum exponent is -308
as it is used above in the DBL_MIN
macro? In the case of the maximum exponent it is defined with 308
which I can understand as it is used by the DBL_MAX
macro.
#define __DBL_MAX_10_EXP__ 308
#define __DBL_MIN_10_EXP__ (-307)
Not part of the question, just observations I made:
By the way using Windows with Visual Studio 2015 there are just the DBL_MAX
and DBL_MIN
macros defined without the compiler specific redirection to the versions with the underscore. Further the minimum positive double value DBL_MIN
and the maximum double value DBL_MAX
are a little bit greater than the values from my Linux gcc compiler (just compared to the defined macros from gcc v4.8.5 above):
#define DBL_MAX 1.7976931348623158e+308
#define DBL_MIN 2.2250738585072014e–308
Moreover the Microsoft compiler set the long double
limits to the values of a double
, seems that it doesn't support a real long double
implementation.