1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
10 #include "mozilla/FloatingPoint.h"
15 #include "vm/JSContext.h"
19 inline double NumberDiv(double a
, double b
) {
20 AutoUnsafeCallWithABI unsafe
;
22 if (a
== 0 || std::isnan(a
)) {
23 return JS::GenericNaN();
25 if (mozilla::IsNegative(a
) != mozilla::IsNegative(b
)) {
26 return mozilla::NegativeInfinity
<double>();
28 return mozilla::PositiveInfinity
<double>();
34 inline double NumberMod(double a
, double b
) {
35 AutoUnsafeCallWithABI unsafe
;
37 return JS::GenericNaN();
39 double r
= fmod(a
, b
);
41 // Some versions of Windows (Win 10 v1803, v1809) miscompute the sign of zero
42 // results from fmod. The sign should match the sign of the LHS. This bug
43 // only affects 64-bit builds. See bug 1527007.
44 if (mozilla::IsPositiveZero(r
) && mozilla::IsNegative(a
)) {
53 #endif /* jslibmath_h */