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

Side by Side Diff: source/i18n/digitgrouping.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/digitgrouping.h ('k') | source/i18n/digitinterval.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2015, International Business Machines
3 * Corporation and others. All Rights Reserved.
4 *
5 * file name: digitgrouping.cpp
6 */
7
8 #include "unicode/utypes.h"
9
10 #include "digitgrouping.h"
11 #include "smallintformatter.h"
12
13 U_NAMESPACE_BEGIN
14
15 UBool DigitGrouping::isSeparatorAt(
16 int32_t digitsLeftOfDecimal, int32_t digitPos) const {
17 if (!isGroupingEnabled(digitsLeftOfDecimal) || digitPos < fGrouping) {
18 return FALSE;
19 }
20 return ((digitPos - fGrouping) % getGrouping2() == 0);
21 }
22
23 int32_t DigitGrouping::getSeparatorCount(int32_t digitsLeftOfDecimal) const {
24 if (!isGroupingEnabled(digitsLeftOfDecimal)) {
25 return 0;
26 }
27 return (digitsLeftOfDecimal - 1 - fGrouping) / getGrouping2() + 1;
28 }
29
30 UBool DigitGrouping::isGroupingEnabled(int32_t digitsLeftOfDecimal) const {
31 return (isGroupingUsed()
32 && digitsLeftOfDecimal >= fGrouping + getMinGrouping());
33 }
34
35 UBool DigitGrouping::isNoGrouping(
36 int32_t positiveValue, const IntDigitCountRange &range) const {
37 return getSeparatorCount(
38 SmallIntFormatter::estimateDigitCount(positiveValue, range)) == 0;
39 }
40
41 int32_t DigitGrouping::getGrouping2() const {
42 return (fGrouping2 > 0 ? fGrouping2 : fGrouping);
43 }
44
45 int32_t DigitGrouping::getMinGrouping() const {
46 return (fMinGrouping > 0 ? fMinGrouping : 1);
47 }
48
49 void
50 DigitGrouping::clear() {
51 fMinGrouping = 0;
52 fGrouping = 0;
53 fGrouping2 = 0;
54 }
55
56 U_NAMESPACE_END
57
OLDNEW
« no previous file with comments | « source/i18n/digitgrouping.h ('k') | source/i18n/digitinterval.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698