1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 *******************************************************************************
5 * Copyright (C) 2015, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 *******************************************************************************
8 * significantdigitinterval.h
10 * created on: 2015jan6
11 * created by: Travis Keep
14 #ifndef __SIGNIFICANTDIGITINTERVAL_H__
15 #define __SIGNIFICANTDIGITINTERVAL_H__
17 #include "unicode/uobject.h"
18 #include "unicode/utypes.h"
23 * An interval of allowed significant digit counts.
25 class U_I18N_API SignificantDigitInterval
: public UMemory
{
29 * No limits on significant digits.
31 SignificantDigitInterval()
32 : fMax(INT32_MAX
), fMin(0) { }
35 * Make this instance have no limit on significant digits.
43 * Returns TRUE if this object is equal to rhs.
45 UBool
equals(const SignificantDigitInterval
&rhs
) const {
46 return ((fMax
== rhs
.fMax
) && (fMin
== rhs
.fMin
));
50 * Sets maximum significant digits. 0 or negative means no maximum.
52 void setMax(int32_t count
) {
53 fMax
= count
<= 0 ? INT32_MAX
: count
;
57 * Get maximum significant digits. INT32_MAX means no maximum.
59 int32_t getMax() const {
64 * Sets minimum significant digits. 0 or negative means no minimum.
66 void setMin(int32_t count
) {
67 fMin
= count
<= 0 ? 0 : count
;
71 * Get maximum significant digits. 0 means no minimum.
73 int32_t getMin() const {
78 * Returns TRUE if this instance represents no constraints on significant
81 UBool
isNoConstraints() const {
82 return fMin
== 0 && fMax
== INT32_MAX
;
92 #endif // __SIGNIFICANTDIGITINTERVAL_H__