diff options
author | Joachim Sauer <jsauer@google.com> | 2016-04-12 14:44:59 +0100 |
---|---|---|
committer | Joachim Sauer <jsauer@google.com> | 2016-04-22 10:55:50 +0100 |
commit | 86b7d2d760b249da7417f90f09796f3227491aba (patch) | |
tree | 6d5f024aefb0ed4f761e9a6b4993d3348a3c51c1 | |
parent | 7c0783a71eb39182b02e60d1a027252a502125e6 (diff) | |
download | icu-86b7d2d760b249da7417f90f09796f3227491aba.tar.gz |
Allow very large maximumIntegerDigits.
This allows up to 2 billion to be used as the maximum integer digits,
while keeping the default value at the current 309. This change brings
ICU4J in line with ICU4C limits, which is necessary for correct
implementation of java.text.DecimalFormat on ICU4J.
Bug: 27855939
Change-Id: Ia3659afe99eb2f9c715d3d0f73fe4a8ddbc946cf
-rw-r--r-- | android_icu4j/src/main/java/android/icu/text/DecimalFormat.java | 17 | ||||
-rw-r--r-- | icu4j/main/classes/core/src/com/ibm/icu/text/DecimalFormat.java | 17 |
2 files changed, 24 insertions, 10 deletions
diff --git a/android_icu4j/src/main/java/android/icu/text/DecimalFormat.java b/android_icu4j/src/main/java/android/icu/text/DecimalFormat.java index 1cebe44fe..6dc95d167 100644 --- a/android_icu4j/src/main/java/android/icu/text/DecimalFormat.java +++ b/android_icu4j/src/main/java/android/icu/text/DecimalFormat.java @@ -5152,13 +5152,14 @@ public class DecimalFormat extends NumberFormat { /** * Sets the maximum number of digits allowed in the integer portion of a number. This - * override limits the integer digit count to 309. + * override limits the integer digit count to 2,000,000,000 to match ICU4C. * * @see NumberFormat#setMaximumIntegerDigits */ @Override public void setMaximumIntegerDigits(int newValue) { - super.setMaximumIntegerDigits(Math.min(newValue, DOUBLE_INTEGER_DIGITS)); + // Android changed: Allow 2 billion integer digits. + super.setMaximumIntegerDigits(Math.min(newValue, MAX_INTEGER_DIGITS)); } /** @@ -5447,11 +5448,12 @@ public class DecimalFormat extends NumberFormat { // InvalidObjectException("Digit count out of range"); } - // Truncate the maximumIntegerDigits to DOUBLE_INTEGER_DIGITS and + // Android changed: Allow 2 billion integer digits. + // Truncate the maximumIntegerDigits to MAX_INTEGER_DIGITS and // maximumFractionDigits to DOUBLE_FRACTION_DIGITS - if (getMaximumIntegerDigits() > DOUBLE_INTEGER_DIGITS) { - setMaximumIntegerDigits(DOUBLE_INTEGER_DIGITS); + if (getMaximumIntegerDigits() > MAX_INTEGER_DIGITS) { + setMaximumIntegerDigits(MAX_INTEGER_DIGITS); } if (getMaximumFractionDigits() > DOUBLE_FRACTION_DIGITS) { _setMaximumFractionDigits(DOUBLE_FRACTION_DIGITS); @@ -5904,6 +5906,11 @@ public class DecimalFormat extends NumberFormat { * Upper limit on integer and fraction digits for a Java double [Richard/GCL] */ static final int DOUBLE_INTEGER_DIGITS = 309; + // Android changed: Allow 2 billion integer digits. + // This change is necessary to stay feature-compatible in java.text.DecimalFormat which + // used to be implemented using ICU4C (which has a 2 billion integer digits limit) and + // is now implemented based on this class. + static final int MAX_INTEGER_DIGITS = 2000000000; static final int DOUBLE_FRACTION_DIGITS = 340; /** diff --git a/icu4j/main/classes/core/src/com/ibm/icu/text/DecimalFormat.java b/icu4j/main/classes/core/src/com/ibm/icu/text/DecimalFormat.java index 982bd35fc..d50ab20be 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/text/DecimalFormat.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/text/DecimalFormat.java @@ -5223,14 +5223,15 @@ public class DecimalFormat extends NumberFormat { /** * Sets the maximum number of digits allowed in the integer portion of a number. This - * override limits the integer digit count to 309. + * override limits the integer digit count to 2,000,000,000 to match ICU4C. * * @see NumberFormat#setMaximumIntegerDigits * @stable ICU 2.0 */ @Override public void setMaximumIntegerDigits(int newValue) { - super.setMaximumIntegerDigits(Math.min(newValue, DOUBLE_INTEGER_DIGITS)); + // Android changed: Allow 2 billion integer digits. + super.setMaximumIntegerDigits(Math.min(newValue, MAX_INTEGER_DIGITS)); } /** @@ -5534,11 +5535,12 @@ public class DecimalFormat extends NumberFormat { // InvalidObjectException("Digit count out of range"); } - // Truncate the maximumIntegerDigits to DOUBLE_INTEGER_DIGITS and + // Android changed: Allow 2 billion integer digits. + // Truncate the maximumIntegerDigits to MAX_INTEGER_DIGITS and // maximumFractionDigits to DOUBLE_FRACTION_DIGITS - if (getMaximumIntegerDigits() > DOUBLE_INTEGER_DIGITS) { - setMaximumIntegerDigits(DOUBLE_INTEGER_DIGITS); + if (getMaximumIntegerDigits() > MAX_INTEGER_DIGITS) { + setMaximumIntegerDigits(MAX_INTEGER_DIGITS); } if (getMaximumFractionDigits() > DOUBLE_FRACTION_DIGITS) { _setMaximumFractionDigits(DOUBLE_FRACTION_DIGITS); @@ -6009,6 +6011,11 @@ public class DecimalFormat extends NumberFormat { * Upper limit on integer and fraction digits for a Java double [Richard/GCL] */ static final int DOUBLE_INTEGER_DIGITS = 309; + // Android changed: Allow 2 billion integer digits. + // This change is necessary to stay feature-compatible in java.text.DecimalFormat which + // used to be implemented using ICU4C (which has a 2 billion integer digits limit) and + // is now implemented based on this class. + static final int MAX_INTEGER_DIGITS = 2000000000; static final int DOUBLE_FRACTION_DIGITS = 340; /** |