Revert "Android patch: Ticket #11913: Add support for formatting BigDecimal / BigInteger with > 309 digits."
This reverts commit d244484c3fbe0eed229eb39f8559d92e11d9ffd2.
Bug: 27855939
(cherry pick from commit e26c4d535027d7dc55f57af22b9447075b270f4a)
Change-Id: I8d48956e531c1245f00b4a6968f278f4f158e73e
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 1209e6a..1cebe44 100644
--- a/android_icu4j/src/main/java/android/icu/text/DecimalFormat.java
+++ b/android_icu4j/src/main/java/android/icu/text/DecimalFormat.java
@@ -920,10 +920,7 @@
synchronized (digitList) {
digitList.set(number, precision, !useExponentialNotation &&
!areSignificantDigitsUsed());
- // Android patch (ticket #11913) begin.
- return subformat(number, result, fieldPosition, isNegative, false, parseAttr,
- getMaximumIntegerDigits());
- // Android patch (ticket #11913) end.
+ return subformat(number, result, fieldPosition, isNegative, false, parseAttr);
}
}
@@ -1123,10 +1120,7 @@
if (digitList.wasRounded() && roundingMode == BigDecimal.ROUND_UNNECESSARY) {
throw new ArithmeticException("Rounding necessary");
}
- // Android patch (ticket #11913) begin.
- return subformat(number, result, fieldPosition, isNegative, true, parseAttr,
- getMaximumIntegerDigits());
- // Android patch (ticket #11913) end.
+ return subformat(number, result, fieldPosition, isNegative, true, parseAttr);
}
}
@@ -1159,19 +1153,8 @@
if (digitList.wasRounded() && roundingMode == BigDecimal.ROUND_UNNECESSARY) {
throw new ArithmeticException("Rounding necessary");
}
- // Android patch (ticket #11913) begin.
- // If the maximum integer digits are still set to the maximum for double, set the
- // maximum integer digits we will display to the length of the BigInteger, as this can
- // acceptably be longer than 309 digits.
- int maxIntDigits;
- if (getMaximumIntegerDigits() == DOUBLE_INTEGER_DIGITS) {
- maxIntDigits = (digitList.decimalAt == 0) ? 1 : digitList.decimalAt;
- } else {
- maxIntDigits = getMaximumIntegerDigits();
- }
return subformat(number.intValue(), result, fieldPosition, number.signum() < 0, true,
- parseAttr, maxIntDigits);
- // Android patch (ticket #11913) end.
+ parseAttr);
}
}
@@ -1202,19 +1185,8 @@
if (digitList.wasRounded() && roundingMode == BigDecimal.ROUND_UNNECESSARY) {
throw new ArithmeticException("Rounding necessary");
}
- // Android patch (ticket #11913) begin.
- // If the maximum integer digits are still set to the maximum for double, set the
- // maximum integer digits we will display to the length of the BigDecimal, as this can
- // acceptably be longer than 309 digits.
- int maxIntDigits;
- if (getMaximumIntegerDigits() == DOUBLE_INTEGER_DIGITS) {
- maxIntDigits = (digitList.decimalAt == 0) ? 1 : digitList.decimalAt;
- } else {
- maxIntDigits = getMaximumIntegerDigits();
- }
return subformat(number.doubleValue(), result, fieldPosition, number.signum() < 0,
- false, parseAttr, maxIntDigits);
- // Android patch (ticket #11913) end.
+ false, parseAttr);
}
}
@@ -1244,20 +1216,8 @@
if (digitList.wasRounded() && roundingMode == BigDecimal.ROUND_UNNECESSARY) {
throw new ArithmeticException("Rounding necessary");
}
- // Android patch (ticket #11913) begin.
- // If the maximum integer digits are still set to the maximum for double, set the
- // maximum integer digits we will display to the length of the BigDecimal, as this can
- // acceptably be longer than 309 digits.
- int maxIntDigits;
- if (getMaximumIntegerDigits() == DOUBLE_INTEGER_DIGITS) {
- maxIntDigits = (digitList.decimalAt == 0) ? 1 : digitList.decimalAt;
- } else {
- maxIntDigits = getMaximumIntegerDigits();
- }
-
return subformat(number.doubleValue(), result, fieldPosition, number.signum() < 0,
- false, false, maxIntDigits);
- // Android patch (ticket #11913) end.
+ false, false);
}
}
@@ -1296,20 +1256,17 @@
}
}
- // Android patch (ticket #11913) begin.
private StringBuffer subformat(int number, StringBuffer result, FieldPosition fieldPosition,
- boolean isNegative, boolean isInteger, boolean parseAttr,
- int maxIntDig) {
+ boolean isNegative, boolean isInteger, boolean parseAttr) {
if (currencySignCount == CURRENCY_SIGN_COUNT_IN_PLURAL_FORMAT) {
// compute the plural category from the digitList plus other settings
return subformat(currencyPluralInfo.select(getFixedDecimal(number)),
result, fieldPosition, isNegative,
- isInteger, parseAttr, maxIntDig);
+ isInteger, parseAttr);
} else {
- return subformat(result, fieldPosition, isNegative, isInteger, parseAttr, maxIntDig);
+ return subformat(result, fieldPosition, isNegative, isInteger, parseAttr);
}
}
- // Android patch (ticket #11913) end.
/**
* This is ugly, but don't see a better way to do it without major restructuring of the code.
@@ -1357,24 +1314,21 @@
return new FixedDecimal(number, v, f);
}
- // Android patch (ticket #11913) begin.
private StringBuffer subformat(double number, StringBuffer result, FieldPosition fieldPosition,
- boolean isNegative, boolean isInteger, boolean parseAttr,
- int maxIntDig) {
+ boolean isNegative,
+ boolean isInteger, boolean parseAttr) {
if (currencySignCount == CURRENCY_SIGN_COUNT_IN_PLURAL_FORMAT) {
// compute the plural category from the digitList plus other settings
return subformat(currencyPluralInfo.select(getFixedDecimal(number)),
result, fieldPosition, isNegative,
- isInteger, parseAttr, maxIntDig);
+ isInteger, parseAttr);
} else {
- return subformat(result, fieldPosition, isNegative, isInteger, parseAttr, maxIntDig);
+ return subformat(result, fieldPosition, isNegative, isInteger, parseAttr);
}
}
- // Android patch (ticket #11913) end.
- // Android patch (ticket #11913) begin.
private StringBuffer subformat(String pluralCount, StringBuffer result, FieldPosition fieldPosition,
- boolean isNegative, boolean isInteger, boolean parseAttr, int maxIntDig) {
+ boolean isNegative, boolean isInteger, boolean parseAttr) {
// There are 2 ways to activate currency plural format: by applying a pattern with
// 3 currency sign directly, or by instantiate a decimal formatter using
// PLURALCURRENCYSTYLE. For both cases, the number of currency sign in the
@@ -1400,18 +1354,15 @@
// based on pattern alone, and it is already expanded during applying pattern, or
// setDecimalFormatSymbols, or setCurrency.
expandAffixAdjustWidth(pluralCount);
- return subformat(result, fieldPosition, isNegative, isInteger, parseAttr, maxIntDig);
+ return subformat(result, fieldPosition, isNegative, isInteger, parseAttr);
}
- // Android patch (ticket #11913) end.
/**
* Complete the formatting of a finite number. On entry, the
* digitList must be filled in with the correct digits.
*/
- // Android patch (ticket #11913) begin.
private StringBuffer subformat(StringBuffer result, FieldPosition fieldPosition,
- boolean isNegative, boolean isInteger, boolean parseAttr,
- int maxIntDig) {
+ boolean isNegative, boolean isInteger, boolean parseAttr) {
// NOTE: This isn't required anymore because DigitList takes care of this.
//
// // The negative of the exponent represents the number of leading // zeros
@@ -1441,18 +1392,18 @@
if (useExponentialNotation) {
subformatExponential(result, fieldPosition, parseAttr);
} else {
- subformatFixed(result, fieldPosition, isInteger, parseAttr, maxIntDig);
+ subformatFixed(result, fieldPosition, isInteger, parseAttr);
}
int suffixLen = appendAffix(result, isNegative, false, fieldPosition, parseAttr);
addPadding(result, fieldPosition, prefixLen, suffixLen);
return result;
}
- // Android patch (ticket #11913) end.
- // Android patch (ticket #11913) begin.
- private void subformatFixed(StringBuffer result, FieldPosition fieldPosition,
- boolean isInteger, boolean parseAttr, int maxIntDig) {
+ private void subformatFixed(StringBuffer result,
+ FieldPosition fieldPosition,
+ boolean isInteger,
+ boolean parseAttr) {
char [] digits = symbols.getDigitsLocal();
char grouping = currencySignCount == CURRENCY_SIGN_COUNT_ZERO ?
@@ -1460,7 +1411,7 @@
char decimal = currencySignCount == CURRENCY_SIGN_COUNT_ZERO ?
symbols.getDecimalSeparator() : symbols.getMonetaryDecimalSeparator();
boolean useSigDig = areSignificantDigitsUsed();
- // Android patch (ticket #11913) end.
+ int maxIntDig = getMaximumIntegerDigits();
int minIntDig = getMinimumIntegerDigits();
int i;
// [Spark/CDL] Record the integer start index.
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 0703986..982bd35 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
@@ -925,10 +925,7 @@
synchronized (digitList) {
digitList.set(number, precision, !useExponentialNotation &&
!areSignificantDigitsUsed());
- // Android patch (ticket #11913) begin.
- return subformat(number, result, fieldPosition, isNegative, false, parseAttr,
- getMaximumIntegerDigits());
- // Android patch (ticket #11913) end.
+ return subformat(number, result, fieldPosition, isNegative, false, parseAttr);
}
}
@@ -1129,10 +1126,7 @@
if (digitList.wasRounded() && roundingMode == BigDecimal.ROUND_UNNECESSARY) {
throw new ArithmeticException("Rounding necessary");
}
- // Android patch (ticket #11913) begin.
- return subformat(number, result, fieldPosition, isNegative, true, parseAttr,
- getMaximumIntegerDigits());
- // Android patch (ticket #11913) end.
+ return subformat(number, result, fieldPosition, isNegative, true, parseAttr);
}
}
@@ -1167,19 +1161,8 @@
if (digitList.wasRounded() && roundingMode == BigDecimal.ROUND_UNNECESSARY) {
throw new ArithmeticException("Rounding necessary");
}
- // Android patch (ticket #11913) begin.
- // If the maximum integer digits are still set to the maximum for double, set the
- // maximum integer digits we will display to the length of the BigInteger, as this can
- // acceptably be longer than 309 digits.
- int maxIntDigits;
- if (getMaximumIntegerDigits() == DOUBLE_INTEGER_DIGITS) {
- maxIntDigits = (digitList.decimalAt == 0) ? 1 : digitList.decimalAt;
- } else {
- maxIntDigits = getMaximumIntegerDigits();
- }
return subformat(number.intValue(), result, fieldPosition, number.signum() < 0, true,
- parseAttr, maxIntDigits);
- // Android patch (ticket #11913) end.
+ parseAttr);
}
}
@@ -1212,19 +1195,8 @@
if (digitList.wasRounded() && roundingMode == BigDecimal.ROUND_UNNECESSARY) {
throw new ArithmeticException("Rounding necessary");
}
- // Android patch (ticket #11913) begin.
- // If the maximum integer digits are still set to the maximum for double, set the
- // maximum integer digits we will display to the length of the BigDecimal, as this can
- // acceptably be longer than 309 digits.
- int maxIntDigits;
- if (getMaximumIntegerDigits() == DOUBLE_INTEGER_DIGITS) {
- maxIntDigits = (digitList.decimalAt == 0) ? 1 : digitList.decimalAt;
- } else {
- maxIntDigits = getMaximumIntegerDigits();
- }
return subformat(number.doubleValue(), result, fieldPosition, number.signum() < 0,
- false, parseAttr, maxIntDigits);
- // Android patch (ticket #11913) end.
+ false, parseAttr);
}
}
@@ -1256,20 +1228,8 @@
if (digitList.wasRounded() && roundingMode == BigDecimal.ROUND_UNNECESSARY) {
throw new ArithmeticException("Rounding necessary");
}
- // Android patch (ticket #11913) begin.
- // If the maximum integer digits are still set to the maximum for double, set the
- // maximum integer digits we will display to the length of the BigDecimal, as this can
- // acceptably be longer than 309 digits.
- int maxIntDigits;
- if (getMaximumIntegerDigits() == DOUBLE_INTEGER_DIGITS) {
- maxIntDigits = (digitList.decimalAt == 0) ? 1 : digitList.decimalAt;
- } else {
- maxIntDigits = getMaximumIntegerDigits();
- }
-
return subformat(number.doubleValue(), result, fieldPosition, number.signum() < 0,
- false, false, maxIntDigits);
- // Android patch (ticket #11913) end.
+ false, false);
}
}
@@ -1308,20 +1268,17 @@
}
}
- // Android patch (ticket #11913) begin.
private StringBuffer subformat(int number, StringBuffer result, FieldPosition fieldPosition,
- boolean isNegative, boolean isInteger, boolean parseAttr,
- int maxIntDig) {
+ boolean isNegative, boolean isInteger, boolean parseAttr) {
if (currencySignCount == CURRENCY_SIGN_COUNT_IN_PLURAL_FORMAT) {
// compute the plural category from the digitList plus other settings
return subformat(currencyPluralInfo.select(getFixedDecimal(number)),
result, fieldPosition, isNegative,
- isInteger, parseAttr, maxIntDig);
+ isInteger, parseAttr);
} else {
- return subformat(result, fieldPosition, isNegative, isInteger, parseAttr, maxIntDig);
+ return subformat(result, fieldPosition, isNegative, isInteger, parseAttr);
}
}
- // Android patch (ticket #11913) end.
/**
* This is ugly, but don't see a better way to do it without major restructuring of the code.
@@ -1369,24 +1326,21 @@
return new FixedDecimal(number, v, f);
}
- // Android patch (ticket #11913) begin.
private StringBuffer subformat(double number, StringBuffer result, FieldPosition fieldPosition,
- boolean isNegative, boolean isInteger, boolean parseAttr,
- int maxIntDig) {
+ boolean isNegative,
+ boolean isInteger, boolean parseAttr) {
if (currencySignCount == CURRENCY_SIGN_COUNT_IN_PLURAL_FORMAT) {
// compute the plural category from the digitList plus other settings
return subformat(currencyPluralInfo.select(getFixedDecimal(number)),
result, fieldPosition, isNegative,
- isInteger, parseAttr, maxIntDig);
+ isInteger, parseAttr);
} else {
- return subformat(result, fieldPosition, isNegative, isInteger, parseAttr, maxIntDig);
+ return subformat(result, fieldPosition, isNegative, isInteger, parseAttr);
}
}
- // Android patch (ticket #11913) end.
- // Android patch (ticket #11913) begin.
private StringBuffer subformat(String pluralCount, StringBuffer result, FieldPosition fieldPosition,
- boolean isNegative, boolean isInteger, boolean parseAttr, int maxIntDig) {
+ boolean isNegative, boolean isInteger, boolean parseAttr) {
// There are 2 ways to activate currency plural format: by applying a pattern with
// 3 currency sign directly, or by instantiate a decimal formatter using
// PLURALCURRENCYSTYLE. For both cases, the number of currency sign in the
@@ -1412,18 +1366,15 @@
// based on pattern alone, and it is already expanded during applying pattern, or
// setDecimalFormatSymbols, or setCurrency.
expandAffixAdjustWidth(pluralCount);
- return subformat(result, fieldPosition, isNegative, isInteger, parseAttr, maxIntDig);
+ return subformat(result, fieldPosition, isNegative, isInteger, parseAttr);
}
- // Android patch (ticket #11913) end.
/**
* Complete the formatting of a finite number. On entry, the
* digitList must be filled in with the correct digits.
*/
- // Android patch (ticket #11913) begin.
private StringBuffer subformat(StringBuffer result, FieldPosition fieldPosition,
- boolean isNegative, boolean isInteger, boolean parseAttr,
- int maxIntDig) {
+ boolean isNegative, boolean isInteger, boolean parseAttr) {
// NOTE: This isn't required anymore because DigitList takes care of this.
//
// // The negative of the exponent represents the number of leading // zeros
@@ -1453,18 +1404,18 @@
if (useExponentialNotation) {
subformatExponential(result, fieldPosition, parseAttr);
} else {
- subformatFixed(result, fieldPosition, isInteger, parseAttr, maxIntDig);
+ subformatFixed(result, fieldPosition, isInteger, parseAttr);
}
int suffixLen = appendAffix(result, isNegative, false, fieldPosition, parseAttr);
addPadding(result, fieldPosition, prefixLen, suffixLen);
return result;
}
- // Android patch (ticket #11913) end.
- // Android patch (ticket #11913) begin.
- private void subformatFixed(StringBuffer result, FieldPosition fieldPosition,
- boolean isInteger, boolean parseAttr, int maxIntDig) {
+ private void subformatFixed(StringBuffer result,
+ FieldPosition fieldPosition,
+ boolean isInteger,
+ boolean parseAttr) {
char [] digits = symbols.getDigitsLocal();
char grouping = currencySignCount == CURRENCY_SIGN_COUNT_ZERO ?
@@ -1472,7 +1423,7 @@
char decimal = currencySignCount == CURRENCY_SIGN_COUNT_ZERO ?
symbols.getDecimalSeparator() : symbols.getMonetaryDecimalSeparator();
boolean useSigDig = areSignificantDigitsUsed();
- // Android patch (ticket #11913) end.
+ int maxIntDig = getMaximumIntegerDigits();
int minIntDig = getMinimumIntegerDigits();
int i;
// [Spark/CDL] Record the integer start index.