#ifndef SPROUT_MATH_TRUNC_HPP #define SPROUT_MATH_TRUNC_HPP #include #include #include #include #include #include #include #include namespace sprout { namespace math { namespace detail { template< typename FloatType, typename sprout::enabler_if::value>::type = sprout::enabler > inline SPROUT_CONSTEXPR FloatType trunc(FloatType x) { return sprout::math::isinf(x) ? x : std::numeric_limits::max() < x || std::numeric_limits::max() < -x ? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::domain_error("trunc: large float rounding."), x) : x < 0 ? -static_cast(static_cast(-x)) : static_cast(static_cast(x)) ; } template< typename IntType, typename sprout::enabler_if::value>::type = sprout::enabler > inline SPROUT_CONSTEXPR double trunc(IntType x) { return sprout::math::detail::trunc(static_cast(x)); } } // namespace detail using NS_SPROUT_MATH_DETAIL::trunc; } // namespace math using sprout::math::trunc; } // namespace sprout #endif // #ifndef SPROUT_MATH_TRUNC_HPP