#ifndef SPROUT_MATH_LOG10_HPP #define SPROUT_MATH_LOG10_HPP #include #include #include #include #include #include #include #include namespace sprout { namespace math { namespace detail { template inline SPROUT_CONSTEXPR T log10_impl(T x) { return sprout::math::log(x) / sprout::math::ln_ten(); } template< typename FloatType, typename sprout::enabler_if::value>::type = sprout::enabler > inline SPROUT_CONSTEXPR FloatType log10(FloatType x) { return x == 0 ? -std::numeric_limits::infinity() : x == std::numeric_limits::infinity() ? std::numeric_limits::infinity() : x < 0 ? std::numeric_limits::quiet_NaN() #if SPROUT_USE_BUILTIN_CMATH_FUNCTION : std::log10(x) #else : x == 1 ? FloatType(0) : static_cast(sprout::math::detail::log10_impl(static_cast::type>(x))) #endif ; } template< typename IntType, typename sprout::enabler_if::value>::type = sprout::enabler > inline SPROUT_CONSTEXPR double log10(IntType x) { return sprout::math::detail::log10(static_cast(x)); } } // namespace detail using sprout::math::detail::log10; } // namespace math using sprout::math::log10; } // namespace sprout #endif // #ifndef SPROUT_MATH_LOG10_HPP