I know that to get the maximum floating point value we can use DBL_MAX.
To get the maximum negative value is it permissible (and portable) to
use (-DBL_MAX). If it is not, how does one get the maximum negative
representable value in a portable way?
Thanks,
John
Using -DBL_MAX is permissible and portable.
You can also use '-std::numeric_limits<double>::max', which is a bit
convoluted way of getting essentially the same value, except if you need
to repackage your code in a template (parameterized on the FP type, for
example).
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Victor, isn't std::numeric_limits<T>::max a function?
e.g.:
std::numeric_limits<double>::max()
It is a static member of the class template. So, if you add the
parentheses, you get a function call expression. If you don't, you get
a function pointer. The name of the function does not include the
parentheses, the type of the function does (since you need them to
specify the empty argument list). So, yes, in order to use them like
you would DBL_MAX, the parentheses are needed. Thanks for pointing that
out.
Thanks Victor.
John