DBL_MAX

J

John

Hi,

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
 
V

Victor Bazarov

John said:
Hi,

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?

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
 
R

red floyd

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).

Victor, isn't std::numeric_limits<T>::max a function?

e.g.:

std::numeric_limits<double>::max()
 
J

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).

Thanks Victor.

John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,097
Latest member
RayE496148

Latest Threads

Top