mfbt/decimal/comparison-with-nan.patch

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mfbt/decimal/comparison-with-nan.patch	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,67 @@
     1.4 +diff --git a/mfbt/decimal/Decimal.cpp b/mfbt/decimal/Decimal.cpp
     1.5 +--- a/mfbt/decimal/Decimal.cpp
     1.6 ++++ b/mfbt/decimal/Decimal.cpp
     1.7 +@@ -505,21 +505,25 @@ Decimal Decimal::operator/(const Decimal
     1.8 +     if (remainder > divisor / 2)
     1.9 +         ++result;
    1.10 + 
    1.11 +     return Decimal(resultSign, resultExponent, result);
    1.12 + }
    1.13 + 
    1.14 + bool Decimal::operator==(const Decimal& rhs) const
    1.15 + {
    1.16 ++    if (isNaN() || rhs.isNaN())
    1.17 ++        return false;
    1.18 +     return m_data == rhs.m_data || compareTo(rhs).isZero();
    1.19 + }
    1.20 + 
    1.21 + bool Decimal::operator!=(const Decimal& rhs) const
    1.22 + {
    1.23 ++    if (isNaN() || rhs.isNaN())
    1.24 ++        return true;
    1.25 +     if (m_data == rhs.m_data)
    1.26 +         return false;
    1.27 +     const Decimal result = compareTo(rhs);
    1.28 +     if (result.isNaN())
    1.29 +         return false;
    1.30 +     return !result.isZero();
    1.31 + }
    1.32 + 
    1.33 +@@ -528,16 +532,18 @@ bool Decimal::operator<(const Decimal& r
    1.34 +     const Decimal result = compareTo(rhs);
    1.35 +     if (result.isNaN())
    1.36 +         return false;
    1.37 +     return !result.isZero() && result.isNegative();
    1.38 + }
    1.39 + 
    1.40 + bool Decimal::operator<=(const Decimal& rhs) const
    1.41 + {
    1.42 ++    if (isNaN() || rhs.isNaN())
    1.43 ++        return false;
    1.44 +     if (m_data == rhs.m_data)
    1.45 +         return true;
    1.46 +     const Decimal result = compareTo(rhs);
    1.47 +     if (result.isNaN())
    1.48 +         return false;
    1.49 +     return result.isZero() || result.isNegative();
    1.50 + }
    1.51 + 
    1.52 +@@ -546,16 +552,18 @@ bool Decimal::operator>(const Decimal& r
    1.53 +     const Decimal result = compareTo(rhs);
    1.54 +     if (result.isNaN())
    1.55 +         return false;
    1.56 +     return !result.isZero() && result.isPositive();
    1.57 + }
    1.58 + 
    1.59 + bool Decimal::operator>=(const Decimal& rhs) const
    1.60 + {
    1.61 ++    if (isNaN() || rhs.isNaN())
    1.62 ++        return false;
    1.63 +     if (m_data == rhs.m_data)
    1.64 +         return true;
    1.65 +     const Decimal result = compareTo(rhs);
    1.66 +     if (result.isNaN())
    1.67 +         return false;
    1.68 +     return result.isZero() || !result.isNegative();
    1.69 + }
    1.70 + 

mercurial