setMultiplier(newValue);
break;
+ case UNUM_SCALE:
+ setScale(newValue);
+ break;
+
case UNUM_GROUPING_SIZE:
setGroupingSize(newValue);
break;
status = U_UNSUPPORTED_ERROR;
break;
}
- // TODO: UNUM_SCALE?
// TODO: UNUM_FORMAT_FAIL_IF_MORE_THAN_MAX_DIGITS?
return *this;
}
case UNUM_MULTIPLIER:
return getMultiplier();
+ case UNUM_SCALE:
+ return getScale();
+
case UNUM_GROUPING_SIZE:
return getGroupingSize();
break;
}
// TODO: UNUM_FORMAT_FAIL_IF_MORE_THAN_MAX_DIGITS?
- // TODO: UNUM_SCALE?
return -1; /* undefined */
}
refreshFormatterNoError();
}
+int32_t DecimalFormat::getScale() const {
+ return fProperties->scaleMultiplier;
+}
+
+void DecimalFormat::setScale(int32_t newValue) {
+ fProperties->scaleMultiplier = newValue;
+ refreshFormatterNoError();
+}
+
double DecimalFormat::getRoundingIncrement(void) const {
return fExportedProperties->roundingIncrement;
}
positiveSuffixPattern.setToBogus();
roundingIncrement = 0.0;
roundingMode.nullify();
+ scaleMultiplier = 0;
secondaryGroupingSize = -1;
signAlwaysShown = false;
}
eq = eq && positiveSuffixPattern == other.positiveSuffixPattern;
eq = eq && roundingIncrement == other.roundingIncrement;
eq = eq && roundingMode == other.roundingMode;
+ eq = eq && scaleMultiplier == other.scaleMultiplier;
eq = eq && secondaryGroupingSize == other.secondaryGroupingSize;
eq = eq && signAlwaysShown == other.signAlwaysShown;
return eq;
* For a percentage, set the suffixes to have "%" and the multiplier to be 100.
* (For Arabic, use arabic percent symbol).
* For a permill, set the suffixes to have "\\u2031" and the multiplier to be 1000.
+ * It is possible to set both via setMultiplier() as via setScale() simultaneously.
*
* @param newValue the new value of the multiplier for use in percent, permill, etc.
* Examples: with 100, 1.23 -> "123", and "123" -> 1.23
*/
virtual void setMultiplier(int32_t newValue);
+ /**
+ * Gets a multiplier for the given power of ten.
+ * For example, scale of 2 corresponds to a multiplier of 100.
+ *
+ * @return the multiplier for use in percent, permill, etc.
+ * Examples: with 100, 1.23 -> "123", and "123" -> 1.23
+ * @draft ICU 62
+ */
+ int32_t getScale(void) const;
+
+ /**
+ * Sets a multiplier for the given power of ten.
+ * For example, scale of 2 corresponds to a multiplier of 100.
+ * It is possible to set both via setMultiplier() as via setScale() simultaneously.
+ *
+ * @param newValue the new value of the multiplier for use in percent, permill, etc.
+ * Examples: with 100, 1.23 -> "123", and "123" -> 1.23
+ * @draft ICU 62
+ */
+ virtual void setScale(int32_t newValue);
+
/**
* Get the rounding increment.
* @return A positive rounding increment, or 0.0 if a custom rounding