Default ilogb implementation should handle special values.

More work is needed here...
This commit is contained in:
jzmaddock
2016-05-31 09:55:57 +01:00
parent dddcf2b00b
commit 37e81ec146

View File

@@ -1212,6 +1212,15 @@ inline typename B::exponent_type eval_ilogb(const B& val)
{
BOOST_STATIC_ASSERT_MSG(!std::numeric_limits<number<B> >::is_specialized || (std::numeric_limits<number<B> >::radix == 2), "The default implementation of ilogb requires a base 2 number type");
typename B::exponent_type e;
switch(eval_fpclassify(val))
{
case FP_NAN:
return (std::numeric_limits<typename B::exponent_type>::min)();
case FP_INFINITE:
return (std::numeric_limits<typename B::exponent_type>::max)();
case FP_ZERO:
return (std::numeric_limits<typename B::exponent_type>::min)();
}
B result;
eval_frexp(result, val, &e);
return e - 1;