summaryrefslogtreecommitdiffstats
path: root/icu/src/main/native
diff options
context:
space:
mode:
authorJesse Wilson <jessewilson@google.com>2009-10-12 14:07:16 -0700
committerJesse Wilson <jessewilson@google.com>2009-10-12 14:30:07 -0700
commit1bf75229139701cbdc5d6823ed81094233cfdebe (patch)
tree47f5129580f9d7268ef64d43eadf0f51f1ae547d /icu/src/main/native
parente3f589fa090e549eb575548916a4bb9df28dd064 (diff)
downloadlibcore-1bf75229139701cbdc5d6823ed81094233cfdebe.zip
libcore-1bf75229139701cbdc5d6823ed81094233cfdebe.tar.gz
libcore-1bf75229139701cbdc5d6823ed81094233cfdebe.tar.bz2
Bug fixing for NumberFormat and BigDecimal.
1. Fixed the bug that DecimalFormat does not handle multiplier. 2. Fixed the bug that DecimalFormat does not handle precision. This is a copy of the original Eclair change, https://android-git.corp.google.com/g/26297 Bug: 1897917.
Diffstat (limited to 'icu/src/main/native')
-rw-r--r--icu/src/main/native/DecimalFormatInterface.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/icu/src/main/native/DecimalFormatInterface.cpp b/icu/src/main/native/DecimalFormatInterface.cpp
index 252ec33..f553e0a 100644
--- a/icu/src/main/native/DecimalFormatInterface.cpp
+++ b/icu/src/main/native/DecimalFormatInterface.cpp
@@ -505,6 +505,8 @@ static jstring formatDigitList(JNIEnv *env, jclass clazz, jint addr, jstring val
const char *digits = (isPositive ? valueChars : valueChars + 1);
int length = strlen(digits);
+ DecimalFormat* fmt = reinterpret_cast<DecimalFormat*>(static_cast<uintptr_t>(addr));
+
// The length of our digit list buffer must be the actual string length + 3,
// because ICU will append some additional characters at the head and at the
// tail of the string, in order to keep strtod() happy:
@@ -524,7 +526,8 @@ static jstring formatDigitList(JNIEnv *env, jclass clazz, jint addr, jstring val
digitList.fDecimalAt = digitList.fCount - scale;
digitList.fIsPositive = isPositive;
- digitList.fRoundingMode = DecimalFormat::kRoundHalfUp;
+ digitList.fRoundingMode = fmt->getRoundingMode();
+ digitList.round(fmt->getMaximumFractionDigits() + digitList.fDecimalAt);
UChar *result = NULL;
@@ -540,8 +543,6 @@ static jstring formatDigitList(JNIEnv *env, jclass clazz, jint addr, jstring val
attrBuffer->bufferSize = 128;
attrBuffer->buffer = (char *) calloc(129 * sizeof(char), 1);
- DecimalFormat *fmt = (DecimalFormat *)(int)addr;
-
UnicodeString res;
fmt->subformat(res, fp, attrBuffer, digitList, isInteger);