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:
parent
fca3a2e724
commit
5c10e4d85c
5 changed files with 186 additions and 9 deletions
|
@ -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
|
||||
//
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue