]>
git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/digitgrouping.cpp
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 * Copyright (C) 2015, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 * file name: digitgrouping.cpp
10 #include "unicode/utypes.h"
12 #include "digitgrouping.h"
13 #include "smallintformatter.h"
17 UBool
DigitGrouping::isSeparatorAt(
18 int32_t digitsLeftOfDecimal
, int32_t digitPos
) const {
19 if (!isGroupingEnabled(digitsLeftOfDecimal
) || digitPos
< fGrouping
) {
22 return ((digitPos
- fGrouping
) % getGrouping2() == 0);
25 int32_t DigitGrouping::getSeparatorCount(int32_t digitsLeftOfDecimal
) const {
26 if (!isGroupingEnabled(digitsLeftOfDecimal
)) {
29 return (digitsLeftOfDecimal
- 1 - fGrouping
) / getGrouping2() + 1;
32 UBool
DigitGrouping::isGroupingEnabled(int32_t digitsLeftOfDecimal
) const {
33 return (isGroupingUsed()
34 && digitsLeftOfDecimal
>= fGrouping
+ getMinGrouping());
37 UBool
DigitGrouping::isNoGrouping(
38 int32_t positiveValue
, const IntDigitCountRange
&range
) const {
39 return getSeparatorCount(
40 SmallIntFormatter::estimateDigitCount(positiveValue
, range
)) == 0;
43 int32_t DigitGrouping::getGrouping2() const {
44 return (fGrouping2
> 0 ? fGrouping2
: fGrouping
);
47 int32_t DigitGrouping::getMinGrouping() const {
48 return (fMinGrouping
> 0 ? fMinGrouping
: 1);
52 DigitGrouping::clear() {