summaryrefslogtreecommitdiffstats
path: root/mfbt/decimal/comparison-with-nan.patch
blob: 477a6143758848d760cbbbbc171d2de922ea80a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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();
 }