[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: [OFFTOPIC] std::numeric_limits<double>::min() question.
From:       Thiago Macieira <thiago () kde ! org>
Date:       2006-04-26 20:31:55
Message-ID: 200604262232.06392.thiago () kde ! org
[Download RAW message or body]

[Attachment #2 (multipart/signed)]


Dmitry Suzdalev wrote:
>double maxd = std::numeric_limits<double>::min();

>Gdb shows me that after initialisation 'maxd' is a _positive_ (and of
> course huge) value!
>Isn't it meant to be negative (despite of how it's internally stored in
>"internals")? :)
>
>Note, that if I change the second line to
>
>double maxd = - std::numeric_limits<double>::max();
>
>then all works as I expect!
>But I'd rather do without such tricks and write the code that's
> straitforward and less messy ;).
>
>What am I getting wrong?

I'm sorry, but the first thing you should do, before posting a message to 
a mailing list, is to think "have I researched enough? will I make myself 
look stupid if I post this question?"

As it turns out, you did not do your homework. Googling 
for "std::numeric_limits" yields the APIDOX for libstdc++:
http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/structstd_1_1numeric__limits.html

If you click "min", you get the following description:
The minimum finite value, or for floating types with denormalization, the 
minimum positive normalized value.

So there's your explanation: std::numeric_limits<double>::min() is the 
minimum positive value.
-- 
Thiago Macieira  -  thiago (AT) macieira.info - thiago (AT) kde.org
  thiago.macieira (AT) trolltech.com     Trolltech AS
    GPG: 0x6EF45358                   |  Sandakerveien 116,
    E067 918B B660 DBD1 105C          |  NO-0402
    966C 33F5 F005 6EF4 5358          |  Oslo, Norway

[Attachment #5 (application/pgp-signature)]

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic