mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-08-03 12:49:50 +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
|
@ -18,30 +18,29 @@
|
|||
|
||||
namespace sprout {
|
||||
namespace math {
|
||||
namespace detail {
|
||||
template<
|
||||
typename FloatType,
|
||||
typename sprout::enabler_if<std::is_floating_point<FloatType>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR int
|
||||
float2_exponent(FloatType x) {
|
||||
return sprout::math::isnan(x) ? 0
|
||||
: x == 0 ? 0
|
||||
: x == sprout::numeric_limits<FloatType>::infinity() || x == -sprout::numeric_limits<FloatType>::infinity() ? 0
|
||||
: sprout::math::ilogb2(x) + 1
|
||||
;
|
||||
}
|
||||
template<
|
||||
typename IntType,
|
||||
typename sprout::enabler_if<std::is_integral<IntType>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR int
|
||||
float2_exponent(IntType x) {
|
||||
return sprout::math::detail::float2_exponent(static_cast<double>(x));
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
using sprout::math::detail::float2_exponent;
|
||||
//
|
||||
// float2_exponent
|
||||
//
|
||||
template<
|
||||
typename FloatType,
|
||||
typename sprout::enabler_if<std::is_floating_point<FloatType>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR int
|
||||
float2_exponent(FloatType x) {
|
||||
return sprout::math::isnan(x) ? 0
|
||||
: x == 0 ? 0
|
||||
: x == sprout::numeric_limits<FloatType>::infinity() || x == -sprout::numeric_limits<FloatType>::infinity() ? 0
|
||||
: sprout::math::ilogb2(x) + 1
|
||||
;
|
||||
}
|
||||
template<
|
||||
typename IntType,
|
||||
typename sprout::enabler_if<std::is_integral<IntType>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR int
|
||||
float2_exponent(IntType x) {
|
||||
return sprout::math::float2_exponent(static_cast<double>(x));
|
||||
}
|
||||
} // namespace math
|
||||
|
||||
using sprout::math::float2_exponent;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue