Bug 1527007 - Work around Windows fmod bugs r=jandem

Differential Revision: https://phabricator.services.mozilla.com/D21407

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ted Campbell 2019-02-28 13:22:17 +00:00
Родитель 3a13844ccd
Коммит 19ce0ac165
1 изменённых файлов: 10 добавлений и 1 удалений

Просмотреть файл

@ -36,7 +36,16 @@ inline double NumberMod(double a, double b) {
if (b == 0) {
return JS::GenericNaN();
}
return fmod(a, b);
double r = fmod(a, b);
#if defined(XP_WIN)
// Some versions of Windows (Win 10 v1803, v1809) miscompute the sign of zero
// results from fmod. The sign should match the sign of the LHS. This bug
// only affects 64-bit builds. See bug 1527007.
if (mozilla::IsPositiveZero(r) && mozilla::IsNegative(a)) {
return -0.0;
}
#endif
return r;
}
} // namespace js