本文整理汇总了C++中mozilla::IsInfinite方法的典型用法代码示例。如果您正苦于以下问题:C++ mozilla::IsInfinite方法的具体用法?C++ mozilla::IsInfinite怎么用?C++ mozilla::IsInfinite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozilla
的用法示例。
在下文中一共展示了mozilla::IsInfinite方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: js_copysign
double
js::ecmaAtan2(double y, double x)
{
#if defined(_MSC_VER)
/*
* MSVC's atan2 does not yield the result demanded by ECMA when both x
* and y are infinite.
* - The result is a multiple of pi/4.
* - The sign of y determines the sign of the result.
* - The sign of x determines the multiplicator, 1 or 3.
*/
if (IsInfinite(y) && IsInfinite(x)) {
double z = js_copysign(M_PI / 4, y);
if (x < 0)
z *= 3;
return z;
}
#endif
#if defined(SOLARIS) && defined(__GNUC__)
if (y == 0) {
if (IsNegativeZero(x))
return js_copysign(M_PI, y);
if (x == 0)
return y;
}
#endif
return atan2(y, x);
}
示例2: while
double
js::powi(double x, int y)
{
unsigned n = (y < 0) ? -y : y;
double m = x;
double p = 1;
while (true) {
if ((n & 1) != 0) p *= m;
n >>= 1;
if (n == 0) {
if (y < 0) {
// Unfortunately, we have to be careful when p has reached
// infinity in the computation, because sometimes the higher
// internal precision in the pow() implementation would have
// given us a finite p. This happens very rarely.
double result = 1.0 / p;
return (result == 0 && IsInfinite(p))
? pow(x, static_cast<double>(y)) // Avoid pow(double, int).
: result;
}
return p;
}
m *= m;
}
}
示例3: NumberValueToStringBuffer
static bool
RenderDouble(WasmRenderContext& c, double num)
{
if (IsNegativeZero(num))
return c.buffer.append("-0");
if (IsNaN(num))
return c.buffer.append("nan");
if (IsInfinite(num)) {
if (num > 0)
return c.buffer.append("infinity");
return c.buffer.append("-infinity");
}
return NumberValueToStringBuffer(c.cx, DoubleValue(num), c.buffer);
}
示例4: RenderNaN
static bool
RenderDouble(WasmRenderContext& c, double d)
{
if (IsNaN(d))
return RenderNaN(c.sb(), d);
if (IsNegativeZero(d))
return c.buffer.append("-0");
if (IsInfinite(d)) {
if (d > 0)
return c.buffer.append("infinity");
return c.buffer.append("-infinity");
}
return NumberValueToStringBuffer(c.cx, DoubleValue(d), c.sb());
}
示例5:
static void
TestPredicates()
{
MOZ_ASSERT(IsNaN(UnspecifiedNaN()));
MOZ_ASSERT(IsNaN(SpecificNaN(1, 17)));;
MOZ_ASSERT(IsNaN(SpecificNaN(0, 0xfffffffffff0fULL)));
MOZ_ASSERT(!IsNaN(0));
MOZ_ASSERT(!IsNaN(-0.0));
MOZ_ASSERT(!IsNaN(1.0));
MOZ_ASSERT(!IsNaN(PositiveInfinity()));
MOZ_ASSERT(!IsNaN(NegativeInfinity()));
MOZ_ASSERT(IsInfinite(PositiveInfinity()));
MOZ_ASSERT(IsInfinite(NegativeInfinity()));
MOZ_ASSERT(!IsInfinite(UnspecifiedNaN()));
MOZ_ASSERT(!IsInfinite(0));
MOZ_ASSERT(!IsInfinite(-0.0));
MOZ_ASSERT(!IsInfinite(1.0));
MOZ_ASSERT(!IsFinite(PositiveInfinity()));
MOZ_ASSERT(!IsFinite(NegativeInfinity()));
MOZ_ASSERT(!IsFinite(UnspecifiedNaN()));
MOZ_ASSERT(IsFinite(0));
MOZ_ASSERT(IsFinite(-0.0));
MOZ_ASSERT(IsFinite(1.0));
MOZ_ASSERT(!IsNegative(PositiveInfinity()));
MOZ_ASSERT(IsNegative(NegativeInfinity()));
MOZ_ASSERT(IsNegative(-0.0));
MOZ_ASSERT(!IsNegative(0.0));
MOZ_ASSERT(IsNegative(-1.0));
MOZ_ASSERT(!IsNegative(1.0));
MOZ_ASSERT(!IsNegativeZero(PositiveInfinity()));
MOZ_ASSERT(!IsNegativeZero(NegativeInfinity()));
MOZ_ASSERT(!IsNegativeZero(SpecificNaN(1, 17)));;
MOZ_ASSERT(!IsNegativeZero(SpecificNaN(1, 0xfffffffffff0fULL)));
MOZ_ASSERT(!IsNegativeZero(SpecificNaN(0, 17)));;
MOZ_ASSERT(!IsNegativeZero(SpecificNaN(0, 0xfffffffffff0fULL)));
MOZ_ASSERT(!IsNegativeZero(UnspecifiedNaN()));
MOZ_ASSERT(IsNegativeZero(-0.0));
MOZ_ASSERT(!IsNegativeZero(0.0));
MOZ_ASSERT(!IsNegativeZero(-1.0));
MOZ_ASSERT(!IsNegativeZero(1.0));
int32_t i;
MOZ_ASSERT(DoubleIsInt32(0.0, &i)); MOZ_ASSERT(i == 0);
MOZ_ASSERT(!DoubleIsInt32(-0.0, &i));
MOZ_ASSERT(DoubleEqualsInt32(0.0, &i)); MOZ_ASSERT(i == 0);
MOZ_ASSERT(DoubleEqualsInt32(-0.0, &i)); MOZ_ASSERT(i == 0);
MOZ_ASSERT(DoubleIsInt32(INT32_MIN, &i)); MOZ_ASSERT(i == INT32_MIN);
MOZ_ASSERT(DoubleIsInt32(INT32_MAX, &i)); MOZ_ASSERT(i == INT32_MAX);
MOZ_ASSERT(DoubleEqualsInt32(INT32_MIN, &i)); MOZ_ASSERT(i == INT32_MIN);
MOZ_ASSERT(DoubleEqualsInt32(INT32_MAX, &i)); MOZ_ASSERT(i == INT32_MAX);
MOZ_ASSERT(!DoubleIsInt32(0.5, &i));
MOZ_ASSERT(!DoubleIsInt32(double(INT32_MAX) + 0.1, &i));
MOZ_ASSERT(!DoubleIsInt32(double(INT32_MIN) - 0.1, &i));
MOZ_ASSERT(!DoubleIsInt32(NegativeInfinity(), &i));
MOZ_ASSERT(!DoubleIsInt32(PositiveInfinity(), &i));
MOZ_ASSERT(!DoubleIsInt32(UnspecifiedNaN(), &i));
MOZ_ASSERT(!DoubleEqualsInt32(0.5, &i));
MOZ_ASSERT(!DoubleEqualsInt32(double(INT32_MAX) + 0.1, &i));
MOZ_ASSERT(!DoubleEqualsInt32(double(INT32_MIN) - 0.1, &i));
MOZ_ASSERT(!DoubleEqualsInt32(NegativeInfinity(), &i));
MOZ_ASSERT(!DoubleEqualsInt32(PositiveInfinity(), &i));
MOZ_ASSERT(!DoubleEqualsInt32(UnspecifiedNaN(), &i));
}