Boost logo

Boost :

Subject: Re: [boost] [math] potentian bug: iround throws, given double( numeric_limits<int>::min() )
From: John Maddock (boost.regex_at_[hidden])
Date: 2011-10-20 07:27:04

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

Ah, yes: when I fixed this bug I had to disable some of new the tests for
type float because of that very issue: an integer type converted to type
float may actually be outside the range of an integer due to rounding during
the conversion.


Boost list run by bdawes at, gregod at, cpdaniel at, john at