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-06 23:57:38 +09:00
parent 7794e56192
commit 56cb7702ea
19 changed files with 157 additions and 69 deletions

View file

@ -6,6 +6,8 @@
#include <stdexcept>
#include <sprout/config.hpp>
#include <sprout/math/detail/config.hpp>
#include <sprout/math/isnan.hpp>
#include <sprout/math/isinf.hpp>
#include <sprout/type_traits/enabler_if.hpp>
#if SPROUT_USE_BUILTIN_CMATH_FUNCTION
# include <sprout/math/floor.hpp>
@ -32,7 +34,9 @@ namespace sprout {
>
inline SPROUT_CONSTEXPR To
ifloor(FloatType x) {
return sprout::math::detail::ifloor_impl<To>(sprout::floor(x));
return sprout::math::isnan(x) || sprout::math::isinf(x) ? std::numeric_limits<To>::min()
: sprout::math::detail::ifloor_impl<To>(sprout::math::floor(x))
;
}
#else
template<typename To, typename FloatType>
@ -49,7 +53,8 @@ namespace sprout {
>
inline SPROUT_CONSTEXPR To
ifloor(FloatType x) {
return x == 0 ? To(0)
return sprout::math::isnan(x) || sprout::math::isinf(x) ? std::numeric_limits<To>::min()
: x == 0 ? To(0)
: std::numeric_limits<To>::max() < x || std::numeric_limits<To>::min() > x
? SPROUT_MATH_THROW_LARGE_FLOAT_ROUNDING(std::runtime_error("ifloor: large float rounding."), static_cast<To>(x))
: sprout::math::detail::ifloor_impl(x, static_cast<To>(x))