mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-07-16 15:14:13 +00:00
fix: math functions (support for inferior C++14 standard)
add C++14 constexpr modifying algorithms
This commit is contained in:
parent
58cff54e0d
commit
c58c9cc0fc
106 changed files with 3465 additions and 2144 deletions
|
@ -27,32 +27,32 @@ namespace sprout {
|
|||
typedef sprout::pair<T, int> type;
|
||||
return type(x / sprout::detail::pow_n(T(sprout::numeric_limits<T>::radix), exp), exp);
|
||||
}
|
||||
|
||||
template<
|
||||
typename FloatType,
|
||||
typename sprout::enabler_if<std::is_floating_point<FloatType>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR sprout::pair<FloatType, int>
|
||||
float_sig_exp(FloatType x) {
|
||||
typedef sprout::pair<FloatType, int> type;
|
||||
return sprout::math::isnan(x) ? type(x, 0)
|
||||
: x == sprout::numeric_limits<FloatType>::infinity() ? type(sprout::numeric_limits<FloatType>::infinity(), 0)
|
||||
: x == -sprout::numeric_limits<FloatType>::infinity() ? type(-sprout::numeric_limits<FloatType>::infinity(), 0)
|
||||
: x == 0 ? type(x, 0)
|
||||
: sprout::math::detail::float_sig_exp_impl(x, sprout::math::ilogb(x) + 1)
|
||||
;
|
||||
}
|
||||
template<
|
||||
typename IntType,
|
||||
typename sprout::enabler_if<std::is_integral<IntType>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR sprout::pair<double, int>
|
||||
float_sig_exp(IntType x) {
|
||||
return sprout::math::detail::float_sig_exp(static_cast<double>(x));
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
using sprout::math::detail::float_sig_exp;
|
||||
//
|
||||
// float_sig_exp
|
||||
//
|
||||
template<
|
||||
typename FloatType,
|
||||
typename sprout::enabler_if<std::is_floating_point<FloatType>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR sprout::pair<FloatType, int>
|
||||
float_sig_exp(FloatType x) {
|
||||
typedef sprout::pair<FloatType, int> type;
|
||||
return sprout::math::isnan(x) ? type(x, 0)
|
||||
: x == sprout::numeric_limits<FloatType>::infinity() ? type(sprout::numeric_limits<FloatType>::infinity(), 0)
|
||||
: x == -sprout::numeric_limits<FloatType>::infinity() ? type(-sprout::numeric_limits<FloatType>::infinity(), 0)
|
||||
: x == 0 ? type(x, 0)
|
||||
: sprout::math::detail::float_sig_exp_impl(x, sprout::math::ilogb(x) + 1)
|
||||
;
|
||||
}
|
||||
template<
|
||||
typename IntType,
|
||||
typename sprout::enabler_if<std::is_integral<IntType>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR sprout::pair<double, int>
|
||||
float_sig_exp(IntType x) {
|
||||
return sprout::math::float_sig_exp(static_cast<double>(x));
|
||||
}
|
||||
} // namespace math
|
||||
|
||||
using sprout::math::float_sig_exp;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue