Boost logo

Boost :

Subject: Re: [boost] [math] potentian bug: iround throws, given double( numeric_limits<int>::min() )
From: Krzysztof Czainski (1czajnik_at_[hidden])
Date: 2011-10-20 07:07:22


2011/10/12 John Maddock <boost.regex_at_[hidden]>

> The docs of the Rounding Functions say:
>>
>> If the argument v is either non-finite or else outside the range of the
>> result type, then returns the result of rounding_error: by default this
>> throws an instance of boost::math::rounding_error.
>>
>> So the example shown below seems to show a bug, since
>> std::numeric_limits<int>::min(**) is *not* outside the range of int. Or
>> did I
>> miss something?
>>
>
> It's a bug: the error checking is off by one for negative values.
>
> Fixed in Trunk.
>
> Thanks, John.
>

A thought came to my mind... Theoretically, is it possible for the following
conditions to be true?
static_cast<float>( std::numeric_limits<int>::min() ) <
std::numeric_limits<int>::min()
static_cast<double>( std::numeric_limits<int>::min() ) <
std::numeric_limits<int>::min()
static_cast<long double>( std::numeric_limits<int>::min() ) <
std::numeric_limits<int>::min()
static_cast<float>( std::numeric_limits<int>::max() ) >
std::numeric_limits<int>::max()
static_cast<double>( std::numeric_limits<int>::max() ) >
std::numeric_limits<int>::max()
static_cast<long double>( std::numeric_limits<int>::max() ) >
std::numeric_limits<int>::max()
After all, casting to floating-point may loose precision... I have no
knowledge in this area, so it may be just a silly thought.

Regards
Kris


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk