comparison-with-nan.patch 1.8 KB

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