1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * vim: set ts=8 sts=4 et sw=4 tw=99:
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"
17 * Use system provided math routines.
20 /* The right copysign function is not always named the same thing. */
22 #define js_copysign __builtin_copysign
24 #define js_copysign _copysign
26 #define js_copysign copysign
29 /* Consistency wrapper for platform deviations in fmod() */
31 js_fmod(double d
, double d2
)
35 * Workaround MS fmod bug where 42 % (1/0) => NaN, not 42.
36 * Workaround MS fmod bug where -0 % -N => 0, not -0.
38 if ((mozilla::IsFinite(d
) && mozilla::IsInfinite(d2
)) ||
39 (d
== 0 && mozilla::IsFinite(d2
))) {
49 NumberDiv(double a
, double b
)
52 if (a
== 0 || mozilla::IsNaN(a
)
54 || mozilla::IsNaN(b
) /* XXX MSVC miscompiles such that (NaN == 0) */
57 return JS::GenericNaN();
59 if (mozilla::IsNegative(a
) != mozilla::IsNegative(b
))
60 return mozilla::NegativeInfinity
<double>();
61 return mozilla::PositiveInfinity
<double>();
68 NumberMod(double a
, double b
) {
70 return JS::GenericNaN();
76 #endif /* jslibmath_h */