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

fix math::pow case x is negative and y is integer

This commit is contained in:
bolero-MURAKAMI 2014-07-15 22:25:04 +09:00
parent fca3a2e724
commit 5c10e4d85c
5 changed files with 186 additions and 9 deletions

View file

@ -44,7 +44,11 @@ namespace sprout {
template<typename T>
inline SPROUT_CONSTEXPR T
pow_impl(T x, T y) {
return sprout::math::exp(y * sprout::math::log(x));
return x < 0
? is_odd(y) ? -sprout::math::exp(y * sprout::math::log(-x))
: sprout::math::exp(y * sprout::math::log(-x))
: sprout::math::exp(y * sprout::math::log(x))
;
}
} // namespace detail
//