mfbt/decimal/comparison-with-nan.patch
author Kris Maglione <maglione.k@gmail.com>
Sat, 05 Aug 2017 22:45:33 -0700
changeset 373940 ccda4fb13271486b9840c108d0046c3aa9d13598
parent 284453 4929064f96e0bb142bf82e36230d1b0c8f570c9d
child 476007 d78adc84bde8cb23a2e34c444d48406bd198c797
permissions -rw-r--r--
Bug 1350646: Part 8 - Remove SDK page-mod modules. r=Mossop MozReview-Commit-ID: C3JrCITSjj6

diff --git a/mfbt/decimal/Decimal.cpp b/mfbt/decimal/Decimal.cpp
--- a/mfbt/decimal/Decimal.cpp
+++ b/mfbt/decimal/Decimal.cpp
@@ -509,21 +509,25 @@ Decimal Decimal::operator/(const Decimal
     if (remainder > divisor / 2)
         ++result;
 
     return Decimal(resultSign, resultExponent, result);
 }
 
 bool Decimal::operator==(const Decimal& rhs) const
 {
+    if (isNaN() || rhs.isNaN())
+        return false;
     return m_data == rhs.m_data || compareTo(rhs).isZero();
 }
 
 bool Decimal::operator!=(const Decimal& rhs) const
 {
+    if (isNaN() || rhs.isNaN())
+        return true;
     if (m_data == rhs.m_data)
         return false;
     const Decimal result = compareTo(rhs);
     if (result.isNaN())
         return false;
     return !result.isZero();
 }
 
@@ -532,16 +536,18 @@ bool Decimal::operator<(const Decimal& r
     const Decimal result = compareTo(rhs);
     if (result.isNaN())
         return false;
     return !result.isZero() && result.isNegative();
 }
 
 bool Decimal::operator<=(const Decimal& rhs) const
 {
+    if (isNaN() || rhs.isNaN())
+        return false;
     if (m_data == rhs.m_data)
         return true;
     const Decimal result = compareTo(rhs);
     if (result.isNaN())
         return false;
     return result.isZero() || result.isNegative();
 }
 
@@ -550,16 +556,18 @@ bool Decimal::operator>(const Decimal& r
     const Decimal result = compareTo(rhs);
     if (result.isNaN())
         return false;
     return !result.isZero() && result.isPositive();
 }
 
 bool Decimal::operator>=(const Decimal& rhs) const
 {
+    if (isNaN() || rhs.isNaN())
+        return false;
     if (m_data == rhs.m_data)
         return true;
     const Decimal result = compareTo(rhs);
     if (result.isNaN())
         return false;
     return result.isZero() || !result.isNegative();
 }