From d7171849487b4eb735eb08c3892b78d55c18d526 Mon Sep 17 00:00:00 2001 From: Shane Carr Date: Fri, 7 Sep 2018 07:41:19 -0700 Subject: [PATCH] ICU-11276 Fixing test failure related to number range. --- icu4c/source/i18n/number_decimalquantity.cpp | 22 +++++++++++++------ .../number/DecimalQuantity_AbstractBCD.java | 22 +++++++++++++------ 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/icu4c/source/i18n/number_decimalquantity.cpp b/icu4c/source/i18n/number_decimalquantity.cpp index 17ed7ff188..3e1963d97e 100644 --- a/icu4c/source/i18n/number_decimalquantity.cpp +++ b/icu4c/source/i18n/number_decimalquantity.cpp @@ -1154,8 +1154,13 @@ const char16_t* DecimalQuantity::checkHealth() const { } bool DecimalQuantity::operator==(const DecimalQuantity& other) const { - bool basicEquals = scale == other.scale && precision == other.precision && flags == other.flags - && lOptPos == other.lOptPos && lReqPos == other.lReqPos && rReqPos == other.rReqPos + bool basicEquals = + scale == other.scale + && precision == other.precision + && flags == other.flags + && lOptPos == other.lOptPos + && lReqPos == other.lReqPos + && rReqPos == other.rReqPos && rOptPos == other.rOptPos; if (!basicEquals) { return false; @@ -1163,13 +1168,16 @@ bool DecimalQuantity::operator==(const DecimalQuantity& other) const { if (precision == 0) { return true; - } - for (int m = getUpperDisplayMagnitude(); m >= getLowerDisplayMagnitude(); m--) { - if (getDigit(m) != other.getDigit(m)) { - return false; + } else if (isApproximate) { + return origDouble == other.origDouble && origDelta == other.origDelta; + } else { + for (int m = getUpperDisplayMagnitude(); m >= getLowerDisplayMagnitude(); m--) { + if (getDigit(m) != other.getDigit(m)) { + return false; + } } + return true; } - return true; } UnicodeString DecimalQuantity::toString() const { diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/number/DecimalQuantity_AbstractBCD.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/number/DecimalQuantity_AbstractBCD.java index 0efa2b79a3..351a341cbc 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/impl/number/DecimalQuantity_AbstractBCD.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/number/DecimalQuantity_AbstractBCD.java @@ -1027,8 +1027,13 @@ public abstract class DecimalQuantity_AbstractBCD implements DecimalQuantity { } DecimalQuantity_AbstractBCD _other = (DecimalQuantity_AbstractBCD) other; - boolean basicEquals = scale == _other.scale && precision == _other.precision && flags == _other.flags - && lOptPos == _other.lOptPos && lReqPos == _other.lReqPos && rReqPos == _other.rReqPos + boolean basicEquals = + scale == _other.scale + && precision == _other.precision + && flags == _other.flags + && lOptPos == _other.lOptPos + && lReqPos == _other.lReqPos + && rReqPos == _other.rReqPos && rOptPos == _other.rOptPos; if (!basicEquals) { return false; @@ -1036,13 +1041,16 @@ public abstract class DecimalQuantity_AbstractBCD implements DecimalQuantity { if (precision == 0) { return true; - } - for (int m = getUpperDisplayMagnitude(); m >= getLowerDisplayMagnitude(); m--) { - if (getDigit(m) != _other.getDigit(m)) { - return false; + } else if (isApproximate) { + return origDouble == _other.origDouble && origDelta == _other.origDelta; + } else { + for (int m = getUpperDisplayMagnitude(); m >= getLowerDisplayMagnitude(); m--) { + if (getDigit(m) != _other.getDigit(m)) { + return false; + } } + return true; } - return true; } /**