1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2025-08-03 12:49:50 +00:00

fix math functions

This commit is contained in:
bolero-MURAKAMI 2013-05-08 01:46:40 +09:00
parent 3498e9214f
commit 9247693c63
13 changed files with 159 additions and 67 deletions

View file

@ -1,6 +1,7 @@
#ifndef SPROUT_MATH_FMIN_HPP
#define SPROUT_MATH_FMIN_HPP
#include <limits>
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/math/detail/config.hpp>
@ -17,7 +18,19 @@ namespace sprout {
>
inline SPROUT_CONSTEXPR FloatType
fmin(FloatType x, FloatType y) {
return y < x && !sprout::math::isnan(y) ? y : x;
return sprout::math::isnan(y) ? x
: sprout::math::isnan(x) ? y
: x == -std::numeric_limits<FloatType>::infinity() ? x
: y == std::numeric_limits<FloatType>::infinity() ? x
: y == -std::numeric_limits<FloatType>::infinity() ? y
: x == std::numeric_limits<FloatType>::infinity() ? y
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
: x == 0 && y == 0 ? x
: std::fmin(x, y)
#else
: y < x ? y : x
#endif
;
}
template<
typename ArithmeticType1,
@ -33,7 +46,7 @@ namespace sprout {
}
} // namespace detail
using NS_SPROUT_MATH_DETAIL::fmin;
using sprout::math::detail::fmin;
} // namespace math
using sprout::math::fmin;