diff --git a/mfbt/FloatingPoint.h b/mfbt/FloatingPoint.h index 5f50d4910fc0..df418c8e0849 100644 --- a/mfbt/FloatingPoint.h +++ b/mfbt/FloatingPoint.h @@ -155,20 +155,6 @@ struct FloatingPoint final : private detail::FloatingPointTrait { "all bits accounted for"); }; -/** Determines whether a float/double is NaN. */ -template -static MOZ_ALWAYS_INLINE bool IsNaN(T aValue) { - /* - * A float/double is NaN if all exponent bits are 1 and the significand - * contains at least one non-zero bit. - */ - typedef FloatingPoint Traits; - typedef typename Traits::Bits Bits; - return (BitwiseCast(aValue) & Traits::kExponentBits) == - Traits::kExponentBits && - (BitwiseCast(aValue) & Traits::kSignificandBits) != 0; -} - /** Determines whether a float/double is +Infinity or -Infinity. */ template static MOZ_ALWAYS_INLINE bool IsInfinite(T aValue) { diff --git a/mfbt/tests/TestFloatingPoint.cpp b/mfbt/tests/TestFloatingPoint.cpp index 0379d7157126..7e1fd9e03280 100644 --- a/mfbt/tests/TestFloatingPoint.cpp +++ b/mfbt/tests/TestFloatingPoint.cpp @@ -16,7 +16,6 @@ using mozilla::FuzzyEqualsMultiplicative; using mozilla::IsFinite; using mozilla::IsFloat32Representable; using mozilla::IsInfinite; -using mozilla::IsNaN; using mozilla::IsNegative; using mozilla::IsNegativeZero; using mozilla::IsPositiveZero; @@ -310,15 +309,12 @@ static void TestEqualsIsForNonInteger(T aVal) { }; static void TestDoublesPredicates() { - A(IsNaN(UnspecifiedNaN())); - A(IsNaN(SpecificNaN(1, 17))); + A(std::isnan(UnspecifiedNaN())); + A(std::isnan(SpecificNaN(1, 17))); ; - A(IsNaN(SpecificNaN(0, 0xfffffffffff0fULL))); - A(!IsNaN(0.0)); - A(!IsNaN(-0.0)); - A(!IsNaN(1.0)); - A(!IsNaN(PositiveInfinity())); - A(!IsNaN(NegativeInfinity())); + A(std::isnan(SpecificNaN(0, 0xfffffffffff0fULL))); + A(!std::isnan(PositiveInfinity())); + A(!std::isnan(NegativeInfinity())); A(IsInfinite(PositiveInfinity())); A(IsInfinite(NegativeInfinity())); @@ -412,15 +408,12 @@ static void TestDoublesPredicates() { } static void TestFloatsPredicates() { - A(IsNaN(UnspecifiedNaN())); - A(IsNaN(SpecificNaN(1, 17))); + A(std::isnan(UnspecifiedNaN())); + A(std::isnan(SpecificNaN(1, 17))); ; - A(IsNaN(SpecificNaN(0, 0x7fff0fUL))); - A(!IsNaN(0.0f)); - A(!IsNaN(-0.0f)); - A(!IsNaN(1.0f)); - A(!IsNaN(PositiveInfinity())); - A(!IsNaN(NegativeInfinity())); + A(std::isnan(SpecificNaN(0, 0x7fff0fUL))); + A(!std::isnan(PositiveInfinity())); + A(!std::isnan(NegativeInfinity())); A(IsInfinite(PositiveInfinity())); A(IsInfinite(NegativeInfinity()));