]>
git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/digitinterval.cpp
2 * Copyright (C) 2015, International Business Machines
3 * Corporation and others. All Rights Reserved.
5 * file name: digitinterval.cpp
8 #include "unicode/utypes.h"
10 #include "digitinterval.h"
14 void DigitInterval::expandToContain(const DigitInterval
&rhs
) {
15 if (fSmallestInclusive
> rhs
.fSmallestInclusive
) {
16 fSmallestInclusive
= rhs
.fSmallestInclusive
;
18 if (fLargestExclusive
< rhs
.fLargestExclusive
) {
19 fLargestExclusive
= rhs
.fLargestExclusive
;
23 void DigitInterval::shrinkToFitWithin(const DigitInterval
&rhs
) {
24 if (fSmallestInclusive
< rhs
.fSmallestInclusive
) {
25 fSmallestInclusive
= rhs
.fSmallestInclusive
;
27 if (fLargestExclusive
> rhs
.fLargestExclusive
) {
28 fLargestExclusive
= rhs
.fLargestExclusive
;
32 void DigitInterval::setIntDigitCount(int32_t count
) {
33 fLargestExclusive
= count
< 0 ? INT32_MAX
: count
;
36 void DigitInterval::setFracDigitCount(int32_t count
) {
37 fSmallestInclusive
= count
< 0 ? INT32_MIN
: -count
;
40 void DigitInterval::expandToContainDigit(int32_t digitExponent
) {
41 if (fLargestExclusive
<= digitExponent
) {
42 fLargestExclusive
= digitExponent
+ 1;
43 } else if (fSmallestInclusive
> digitExponent
) {
44 fSmallestInclusive
= digitExponent
;
48 UBool
DigitInterval::contains(int32_t x
) const {
49 return (x
< fLargestExclusive
&& x
>= fSmallestInclusive
);