From 191867afe011d6f5ffcaa6ba0b80e06c9168d5be Mon Sep 17 00:00:00 2001 From: Mitsuru Kariya Date: Wed, 16 Jul 2014 01:03:20 +0900 Subject: [PATCH] fix math::is_odd for a negative argument I think that sprout::math::is_odd(-1) should be true. It also fixes math::pow for a case that x is a negative and y is a negative odd integer. cf. http://melpon.org/wandbox/permlink/XVKea2I6CdVJCbZX --- sprout/math/is_odd.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sprout/math/is_odd.hpp b/sprout/math/is_odd.hpp index 1b29f59c..6e8f6866 100644 --- a/sprout/math/is_odd.hpp +++ b/sprout/math/is_odd.hpp @@ -33,7 +33,7 @@ namespace sprout { inline SPROUT_CONSTEXPR bool is_odd(FloatType x) { return sprout::math::isfinite(x) - && sprout::math::detail::is_odd_unchecked(x) + && sprout::math::detail::is_odd_unchecked(x < 0 ? -x : x) ; } } // namespace math