Commit 954208bb authored by Kent Tamura's avatar Kent Tamura Committed by Commit Bot

WTF: Windows: Remove workaround for atan2(), fmod(), pow() bugs

They work correctly now according to the result of
MathExtrasTest.infinityMath without the workaround.

Change-Id: Ifbf1a0a3f4f717d70b06095ae814919b45fb7677
Reviewed-on: https://chromium-review.googlesource.com/1078187Reviewed-by: default avatarYuta Kitamura <yutak@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#563165}
parent 5a6f4bdd
...@@ -60,51 +60,6 @@ const float piOverFourFloat = static_cast<float>(M_PI_4); ...@@ -60,51 +60,6 @@ const float piOverFourFloat = static_cast<float>(M_PI_4);
const double twoPiDouble = piDouble * 2.0; const double twoPiDouble = piDouble * 2.0;
const float twoPiFloat = piFloat * 2.0f; const float twoPiFloat = piFloat * 2.0f;
#if defined(COMPILER_MSVC)
// VS2013 has most of the math functions now, but we still need to work
// around various differences in behavior of Inf.
// Work around a bug in Win, where atan2(+-infinity, +-infinity) yields NaN
// instead of specific values.
inline double wtf_atan2(double x, double y) {
double posInf = std::numeric_limits<double>::infinity();
double negInf = -std::numeric_limits<double>::infinity();
double nan = std::numeric_limits<double>::quiet_NaN();
double result = nan;
if (x == posInf && y == posInf)
result = piOverFourDouble;
else if (x == posInf && y == negInf)
result = 3 * piOverFourDouble;
else if (x == negInf && y == posInf)
result = -piOverFourDouble;
else if (x == negInf && y == negInf)
result = -3 * piOverFourDouble;
else
result = ::atan2(x, y);
return result;
}
// Work around a bug in the Microsoft CRT, where fmod(x, +-infinity) yields NaN
// instead of x.
inline double wtf_fmod(double x, double y) {
return (!std::isinf(x) && std::isinf(y)) ? x : fmod(x, y);
}
// Work around a bug in the Microsoft CRT, where pow(NaN, 0) yields NaN instead
// of 1.
inline double wtf_pow(double x, double y) {
return y == 0 ? 1 : pow(x, y);
}
#define atan2(x, y) wtf_atan2(x, y)
#define fmod(x, y) wtf_fmod(x, y)
#define pow(x, y) wtf_pow(x, y)
#endif // defined(COMPILER_MSVC)
inline double deg2rad(double d) { inline double deg2rad(double d) {
return d * piDouble / 180.0; return d * piDouble / 180.0;
......
...@@ -235,8 +235,8 @@ TEST(MathExtrasTest, clampToUnsignedLongLongUnsignedLongLong) { ...@@ -235,8 +235,8 @@ TEST(MathExtrasTest, clampToUnsignedLongLongUnsignedLongLong) {
clampTo<unsigned long long>(0xFFFFFFFFFFFFFFF5ULL)); clampTo<unsigned long long>(0xFFFFFFFFFFFFFFF5ULL));
} }
// Make sure that various +-inf cases are handled properly (they aren't // Make sure that various +-inf cases are handled properly (they weren't
// by default on VS). // by default on older VS).
TEST(MathExtrasTest, infinityMath) { TEST(MathExtrasTest, infinityMath) {
double pos_inf = std::numeric_limits<double>::infinity(); double pos_inf = std::numeric_limits<double>::infinity();
double neg_inf = -std::numeric_limits<double>::infinity(); double neg_inf = -std::numeric_limits<double>::infinity();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment