blob: 0e274ce033bad5e9188e992fa1415bdd83a1eed9 (
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/mozglue/misc/decimal/Decimal.cpp b/mozglue/misc/decimal/Decimal.cpp
--- a/mozglue/misc/decimal/Decimal.cpp
+++ b/mozglue/misc/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();
}
|