Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DBL_MAX

1 view
Skip to first unread message

John

unread,
Nov 2, 2009, 7:19:08 AM11/2/09
to
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

Victor Bazarov

unread,
Nov 2, 2009, 9:29:28 AM11/2/09
to

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

red floyd

unread,
Nov 2, 2009, 12:22:03 PM11/2/09
to
On Nov 2, 6:29 am, Victor Bazarov <v.Abaza...@comAcast.net> wrote:
> John wrote:
> > 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).
>

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

e.g.:

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

Victor Bazarov

unread,
Nov 2, 2009, 12:50:45 PM11/2/09
to

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.

John

unread,
Nov 2, 2009, 3:48:37 PM11/2/09
to
>
> 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

0 new messages