diff options
Diffstat (limited to 'mfbt/FloatingPoint.h')
-rw-r--r-- | mfbt/FloatingPoint.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/mfbt/FloatingPoint.h b/mfbt/FloatingPoint.h index 6a0e454ae7..7d73d7e848 100644 --- a/mfbt/FloatingPoint.h +++ b/mfbt/FloatingPoint.h @@ -396,6 +396,20 @@ NumbersAreIdentical(T aValue1, T aValue2) return BitwiseCast<Bits>(aValue1) == BitwiseCast<Bits>(aValue2); } +/** + * Return true if |aValue| and |aValue2| are equal (ignoring sign if both are + * zero) or both NaN. + */ +template <typename T> +static inline bool +EqualOrBothNaN(T aValue1, T aValue2) +{ + if (IsNaN(aValue1)) { + return IsNaN(aValue2); + } + return aValue1 == aValue2; +} + namespace detail { template<typename T> |