}
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;
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 {
}
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;
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;
}
/**