mfbt/decimal/comparison-with-nan.patch

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

michael@0 1 diff --git a/mfbt/decimal/Decimal.cpp b/mfbt/decimal/Decimal.cpp
michael@0 2 --- a/mfbt/decimal/Decimal.cpp
michael@0 3 +++ b/mfbt/decimal/Decimal.cpp
michael@0 4 @@ -505,21 +505,25 @@ Decimal Decimal::operator/(const Decimal
michael@0 5 if (remainder > divisor / 2)
michael@0 6 ++result;
michael@0 7
michael@0 8 return Decimal(resultSign, resultExponent, result);
michael@0 9 }
michael@0 10
michael@0 11 bool Decimal::operator==(const Decimal& rhs) const
michael@0 12 {
michael@0 13 + if (isNaN() || rhs.isNaN())
michael@0 14 + return false;
michael@0 15 return m_data == rhs.m_data || compareTo(rhs).isZero();
michael@0 16 }
michael@0 17
michael@0 18 bool Decimal::operator!=(const Decimal& rhs) const
michael@0 19 {
michael@0 20 + if (isNaN() || rhs.isNaN())
michael@0 21 + return true;
michael@0 22 if (m_data == rhs.m_data)
michael@0 23 return false;
michael@0 24 const Decimal result = compareTo(rhs);
michael@0 25 if (result.isNaN())
michael@0 26 return false;
michael@0 27 return !result.isZero();
michael@0 28 }
michael@0 29
michael@0 30 @@ -528,16 +532,18 @@ bool Decimal::operator<(const Decimal& r
michael@0 31 const Decimal result = compareTo(rhs);
michael@0 32 if (result.isNaN())
michael@0 33 return false;
michael@0 34 return !result.isZero() && result.isNegative();
michael@0 35 }
michael@0 36
michael@0 37 bool Decimal::operator<=(const Decimal& rhs) const
michael@0 38 {
michael@0 39 + if (isNaN() || rhs.isNaN())
michael@0 40 + return false;
michael@0 41 if (m_data == rhs.m_data)
michael@0 42 return true;
michael@0 43 const Decimal result = compareTo(rhs);
michael@0 44 if (result.isNaN())
michael@0 45 return false;
michael@0 46 return result.isZero() || result.isNegative();
michael@0 47 }
michael@0 48
michael@0 49 @@ -546,16 +552,18 @@ bool Decimal::operator>(const Decimal& r
michael@0 50 const Decimal result = compareTo(rhs);
michael@0 51 if (result.isNaN())
michael@0 52 return false;
michael@0 53 return !result.isZero() && result.isPositive();
michael@0 54 }
michael@0 55
michael@0 56 bool Decimal::operator>=(const Decimal& rhs) const
michael@0 57 {
michael@0 58 + if (isNaN() || rhs.isNaN())
michael@0 59 + return false;
michael@0 60 if (m_data == rhs.m_data)
michael@0 61 return true;
michael@0 62 const Decimal result = compareTo(rhs);
michael@0 63 if (result.isNaN())
michael@0 64 return false;
michael@0 65 return result.isZero() || !result.isNegative();
michael@0 66 }
michael@0 67

mercurial