#ifndef SPROUT_MATH_ILOGB2_HPP #define SPROUT_MATH_ILOGB2_HPP #include #include #include #include #include #include #if SPROUT_FLT_RADIX_IS_2 # include #else # include # include # include # include #endif namespace sprout { namespace math { namespace detail { #if SPROUT_FLT_RADIX_IS_2 template< typename FloatType, typename sprout::enabler_if::value>::type = sprout::enabler > inline SPROUT_CONSTEXPR int ilogb2(FloatType x) { return sprout::math::ilogb(x); } template< typename IntType, typename sprout::enabler_if::value>::type = sprout::enabler > inline SPROUT_CONSTEXPR int ilogb2(IntType x) { return sprout::math::ilogb(x); } #else template< typename FloatType, typename sprout::enabler_if::value>::type = sprout::enabler > inline SPROUT_CONSTEXPR int ilogb2(FloatType x) { return sprout::math::iszero(x) ? FP_ILOGB0 : sprout::math::isinf(x) ? INT_MAX : sprout::math::isnan(x) ? FP_ILOGBNAN : static_cast(sprout::math::logb2(x)) ; } template< typename IntType, typename sprout::enabler_if::value>::type = sprout::enabler > inline SPROUT_CONSTEXPR int ilogb2(IntType x) { return sprout::math::detail::ilogb2(static_cast(x)); } #endif } // namespace detail using sprout::math::detail::ilogb2; } // namespace math using sprout::math::ilogb2; } // namespace sprout #endif // #ifndef SPROUT_MATH_ILOGB2_HPP