00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef DIGITLST_H
00025 #define DIGITLST_H
00026
00027 #include "unicode/utypes.h"
00028 #include <float.h>
00029
00030
00031
00032
00052 class U_COMMON_API DigitList {
00053 public:
00054 DigitList();
00055 ~DigitList();
00056
00057 DigitList(const DigitList&);
00058
00059 DigitList& operator=(const DigitList&);
00060
00064 UBool operator==(const DigitList& other) const;
00065
00069 UBool operator!=(const DigitList& other) const { return !operator==(other); }
00070
00078 void clear(void);
00079
00084 inline void append(char digit);
00085
00090 double getDouble(void);
00091
00097 int32_t getLong(void);
00098
00103 UBool fitsIntoLong(UBool ignoreNegativeZero);
00104
00110 void set(double source, int32_t maximumDigits, UBool fixedPoint = TRUE);
00111
00117 void set(int32_t source, int32_t maximumDigits = 0);
00118
00122 UBool isZero(void) const;
00123
00129 UBool isLONG_MIN(void) const;
00130
00135 static const char kZero;
00136
00137 private:
00138 enum {
00139 MAX_DIGITS = DBL_DIG,
00140 MAX_EXPONENT = DBL_DIG,
00141 DIGIT_PADDING = 3,
00142
00143
00144 MAX_DEC_DIGITS = DBL_DIG + DIGIT_PADDING + MAX_EXPONENT
00145 };
00146
00147 public:
00169 int32_t fDecimalAt;
00170 int32_t fCount;
00171 UBool fIsPositive;
00172 char *fDigits;
00173
00174 private:
00175
00176
00177 char fDecimalDigits[MAX_DEC_DIGITS + 1];
00178
00179
00180
00181
00182
00188 void round(int32_t maximumDigits);
00189
00193
00194
00195 UBool shouldRoundUp(int32_t maximumDigits);
00196
00205 static int32_t formatBase10(int32_t number, char *outputStr, int32_t outputLen);
00206 };
00207
00208
00209
00210
00211
00212 inline void
00213 DigitList::append(char digit)
00214 {
00215
00216 if (fCount < MAX_DIGITS)
00217 fDigits[fCount++] = digit;
00218 }
00219
00220 #endif // _DIGITLST
00221
00222
00223
00224