summaryrefslogtreecommitdiff
path: root/mfbt
diff options
context:
space:
mode:
authorJob Bautista <jobbautista9@aol.com>2023-05-10 19:22:39 +0800
committerJob Bautista <jobbautista9@aol.com>2023-05-12 16:26:04 +0800
commitef31c426b19568a72932d9d6982685ad6baf0af6 (patch)
tree57a8553c13941f97acfd88447a21b209d4f22fa6 /mfbt
parent30b5a4d830294cd7496853e449cb5b634ed53fce (diff)
downloaduxp-ef31c426b19568a72932d9d6982685ad6baf0af6.tar.gz
Issue #2241 - Part 2: Add SameValueZero implementation to mfbt/FloatingPoint.h
Backported from Mozilla bug 1560658. This is to prevent duplication of code while implementing DOMMatrix operations.
Diffstat (limited to 'mfbt')
-rw-r--r--mfbt/FloatingPoint.h14
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>