Go Back   Velocity Reviews > Newsgroups > C++
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

C++ - DBL_MAX

 
Thread Tools Search this Thread
Old 11-02-2009, 12:19 PM   #1
Default DBL_MAX


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


John
  Reply With Quote
Old 11-02-2009, 02:29 PM   #2
Victor Bazarov
 
Posts: n/a
Default Re: DBL_MAX
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).

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


Victor Bazarov
  Reply With Quote
Old 11-02-2009, 05:22 PM   #3
red floyd
 
Posts: n/a
Default Re: DBL_MAX
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()



red floyd
  Reply With Quote
Old 11-02-2009, 08:48 PM   #4
John
 
Posts: n/a
Default Re: DBL_MAX
>
> 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


John
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46