Здесь T — long double, а Char имеет тип char. Любые предложения будут оценены.
Код: Выделить всё
template
inline static bool add(T& n, Char ch, mpl::true_) // checked add
{
// Ensure n *= Radix will not overflow
T const max = (std::numeric_limits::max)();
T const val = max / Radix;
if (n > val)
return false;
T tmp = n * Radix; //tmp = 0
// Ensure n += digit will not overflow
const int digit = radix_traits::digit(ch); //digit = 4
if (tmp > max - digit) //This line is throwing SIGFPE.
return false;
n = tmp + static_cast(digit);
return true;
}
};
Код: Выделить всё
long double maxVal = (std::numeric_limits::max)();
int digit = 4;
long double tmpVal = 0; //0 value is result of some calculation and not constant
if(tmpVal > maxVal - digit) //can this line throw SIGFPE.
{
//do something.
}
Подробнее здесь: https://stackoverflow.com/questions/793 ... -exception
Мобильная версия