Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(332)

Side by Side Diff: source/i18n/compactdecimalformat.cpp

Issue 1621843002: ICU 56 update step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@561
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/i18n/collunsafe.h ('k') | source/i18n/csdetect.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 ******************************************************************************* 2 *******************************************************************************
3 * Copyright (C) 1997-2014, International Business Machines Corporation and * 3 * Copyright (C) 1997-2015, International Business Machines Corporation and *
4 * others. All Rights Reserved. * 4 * others. All Rights Reserved. *
5 ******************************************************************************* 5 *******************************************************************************
6 * 6 *
7 * File COMPACTDECIMALFORMAT.CPP 7 * File COMPACTDECIMALFORMAT.CPP
8 * 8 *
9 ******************************************************************************** 9 ********************************************************************************
10 */ 10 */
11 #include "unicode/utypes.h" 11 #include "unicode/utypes.h"
12 12
13 #if !UCONFIG_NO_FORMATTING 13 #if !UCONFIG_NO_FORMATTING
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 UBool 235 UBool
236 CompactDecimalFormat::eqHelper(const CompactDecimalFormat& that) const { 236 CompactDecimalFormat::eqHelper(const CompactDecimalFormat& that) const {
237 return uhash_equals(_unitsByVariant, that._unitsByVariant) && divisors_equal(_ divisors, that._divisors) && (*_pluralRules == *that._pluralRules); 237 return uhash_equals(_unitsByVariant, that._unitsByVariant) && divisors_equal(_ divisors, that._divisors) && (*_pluralRules == *that._pluralRules);
238 } 238 }
239 239
240 UnicodeString& 240 UnicodeString&
241 CompactDecimalFormat::format( 241 CompactDecimalFormat::format(
242 double number, 242 double number,
243 UnicodeString& appendTo, 243 UnicodeString& appendTo,
244 FieldPosition& pos) const { 244 FieldPosition& pos) const {
245 UErrorCode status = U_ZERO_ERROR;
246 return format(number, appendTo, pos, status);
247 }
248
249 UnicodeString&
250 CompactDecimalFormat::format(
251 double number,
252 UnicodeString& appendTo,
253 FieldPosition& pos,
254 UErrorCode &status) const {
255 if (U_FAILURE(status)) {
256 return appendTo;
257 }
245 DigitList orig, rounded; 258 DigitList orig, rounded;
246 orig.set(number); 259 orig.set(number);
247 UBool isNegative; 260 UBool isNegative;
248 UErrorCode status = U_ZERO_ERROR;
249 _round(orig, rounded, isNegative, status); 261 _round(orig, rounded, isNegative, status);
250 if (U_FAILURE(status)) { 262 if (U_FAILURE(status)) {
251 return appendTo; 263 return appendTo;
252 } 264 }
253 double roundedDouble = rounded.getDouble(); 265 double roundedDouble = rounded.getDouble();
254 if (isNegative) { 266 if (isNegative) {
255 roundedDouble = -roundedDouble; 267 roundedDouble = -roundedDouble;
256 } 268 }
257 int32_t baseIdx = computeLog10(roundedDouble, TRUE); 269 int32_t baseIdx = computeLog10(roundedDouble, TRUE);
258 double numberToFormat = roundedDouble / _divisors[baseIdx]; 270 double numberToFormat = roundedDouble / _divisors[baseIdx];
(...skipping 13 matching lines...) Expand all
272 double /* number */, 284 double /* number */,
273 UnicodeString& appendTo, 285 UnicodeString& appendTo,
274 FieldPositionIterator* /* posIter */, 286 FieldPositionIterator* /* posIter */,
275 UErrorCode& status) const { 287 UErrorCode& status) const {
276 status = U_UNSUPPORTED_ERROR; 288 status = U_UNSUPPORTED_ERROR;
277 return appendTo; 289 return appendTo;
278 } 290 }
279 291
280 UnicodeString& 292 UnicodeString&
281 CompactDecimalFormat::format( 293 CompactDecimalFormat::format(
294 int32_t number,
295 UnicodeString& appendTo,
296 FieldPosition& pos) const {
297 return format((double) number, appendTo, pos);
298 }
299
300 UnicodeString&
301 CompactDecimalFormat::format(
302 int32_t number,
303 UnicodeString& appendTo,
304 FieldPosition& pos,
305 UErrorCode &status) const {
306 return format((double) number, appendTo, pos, status);
307 }
308
309 UnicodeString&
310 CompactDecimalFormat::format(
311 int32_t /* number */,
312 UnicodeString& appendTo,
313 FieldPositionIterator* /* posIter */,
314 UErrorCode& status) const {
315 status = U_UNSUPPORTED_ERROR;
316 return appendTo;
317 }
318
319 UnicodeString&
320 CompactDecimalFormat::format(
282 int64_t number, 321 int64_t number,
283 UnicodeString& appendTo, 322 UnicodeString& appendTo,
284 FieldPosition& pos) const { 323 FieldPosition& pos) const {
285 return format((double) number, appendTo, pos); 324 return format((double) number, appendTo, pos);
286 } 325 }
287 326
288 UnicodeString& 327 UnicodeString&
289 CompactDecimalFormat::format( 328 CompactDecimalFormat::format(
329 int64_t number,
330 UnicodeString& appendTo,
331 FieldPosition& pos,
332 UErrorCode &status) const {
333 return format((double) number, appendTo, pos, status);
334 }
335
336 UnicodeString&
337 CompactDecimalFormat::format(
290 int64_t /* number */, 338 int64_t /* number */,
291 UnicodeString& appendTo, 339 UnicodeString& appendTo,
292 FieldPositionIterator* /* posIter */, 340 FieldPositionIterator* /* posIter */,
293 UErrorCode& status) const { 341 UErrorCode& status) const {
294 status = U_UNSUPPORTED_ERROR; 342 status = U_UNSUPPORTED_ERROR;
295 return appendTo; 343 return appendTo;
296 } 344 }
297 345
298 UnicodeString& 346 UnicodeString&
299 CompactDecimalFormat::format( 347 CompactDecimalFormat::format(
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 for (int32_t i = 0; i < MAX_DIGITS; ++i) { 909 for (int32_t i = 0; i < MAX_DIGITS; ++i) {
862 if (!otherUnits[i].isSet()) { 910 if (!otherUnits[i].isSet()) {
863 result->divisors[i] = lastDivisor; 911 result->divisors[i] = lastDivisor;
864 definedInCLDR[i] = FALSE; 912 definedInCLDR[i] = FALSE;
865 } else { 913 } else {
866 lastDivisor = result->divisors[i]; 914 lastDivisor = result->divisors[i];
867 definedInCLDR[i] = TRUE; 915 definedInCLDR[i] = TRUE;
868 } 916 }
869 } 917 }
870 // Iterate over each variant. 918 // Iterate over each variant.
871 int32_t pos = -1; 919 int32_t pos = UHASH_FIRST;
872 const UHashElement* element = uhash_nextElement(result->unitsByVariant, &pos); 920 const UHashElement* element = uhash_nextElement(result->unitsByVariant, &pos);
873 for (;element != NULL; element = uhash_nextElement(result->unitsByVariant, &po s)) { 921 for (;element != NULL; element = uhash_nextElement(result->unitsByVariant, &po s)) {
874 CDFUnit* units = (CDFUnit*) element->value.pointer; 922 CDFUnit* units = (CDFUnit*) element->value.pointer;
875 for (int32_t i = 0; i < MAX_DIGITS; ++i) { 923 for (int32_t i = 0; i < MAX_DIGITS; ++i) {
876 if (definedInCLDR[i]) { 924 if (definedInCLDR[i]) {
877 if (!units[i].isSet()) { 925 if (!units[i].isSet()) {
878 units[i] = otherUnits[i]; 926 units[i] = otherUnits[i];
879 } 927 }
880 } else { 928 } else {
881 if (i == 0) { 929 if (i == 0) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 cdfUnit = (const CDFUnit*) uhash_get(table, cvariant.data()); 990 cdfUnit = (const CDFUnit*) uhash_get(table, cvariant.data());
943 } 991 }
944 if (cdfUnit == NULL) { 992 if (cdfUnit == NULL) {
945 cdfUnit = (const CDFUnit*) uhash_get(table, gOther); 993 cdfUnit = (const CDFUnit*) uhash_get(table, gOther);
946 } 994 }
947 return &cdfUnit[log10Value]; 995 return &cdfUnit[log10Value];
948 } 996 }
949 997
950 U_NAMESPACE_END 998 U_NAMESPACE_END
951 #endif 999 #endif
OLDNEW
« no previous file with comments | « source/i18n/collunsafe.h ('k') | source/i18n/csdetect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698