ICU-3668 make getters const -- can't do much here

X-SVN-Rev: 14789
This commit is contained in:
Alan Liu 2004-03-27 07:43:21 +00:00
parent 1a057ed7e4
commit f6541cfe30
2 changed files with 13 additions and 63 deletions

View file

@ -65,6 +65,7 @@ U_NAMESPACE_BEGIN
DigitList::DigitList()
{
fDigits = fDecimalDigits + 1; // skip the decimal
clear();
}
@ -117,7 +118,6 @@ DigitList::operator==(const DigitList& that) const
void
DigitList::clear()
{
fDigits = fDecimalDigits + 1; // skip the decimal
fDecimalAt = 0;
fCount = 0;
fIsPositive = TRUE;
@ -183,7 +183,7 @@ formatBase10(int64_t number, char *outputStr, int32_t outputLen)
* can be linked to this function.
*/
double
DigitList::getDouble()
DigitList::getDouble() /*const*/
{
double value;
@ -216,7 +216,7 @@ DigitList::getDouble()
/**
* Make sure that fitsIntoLong() is called before calling this function.
*/
int32_t DigitList::getLong()
int32_t DigitList::getLong() /*const*/
{
if (fCount == fDecimalAt) {
int32_t value;
@ -242,7 +242,7 @@ int32_t DigitList::getLong()
/**
* Make sure that fitsIntoInt64() is called before calling this function.
*/
int64_t DigitList::getInt64()
int64_t DigitList::getInt64() /*const*/
{
if (fCount == fDecimalAt) {
uint64_t value;
@ -286,7 +286,7 @@ int64_t DigitList::getInt64()
* a long.
*/
UBool
DigitList::fitsIntoLong(UBool ignoreNegativeZero)
DigitList::fitsIntoLong(UBool ignoreNegativeZero) /*const*/
{
// Figure out if the result will fit in a long. We have to
// first look for nonzero digits after the decimal point;
@ -303,8 +303,6 @@ DigitList::fitsIntoLong(UBool ignoreNegativeZero)
return fIsPositive || ignoreNegativeZero;
}
// initializeLONG_MIN_REP();
// If the digit list represents a double or this number is too
// big for a long.
if (fDecimalAt < fCount || fDecimalAt > LONG_MIN_REP_LENGTH)
@ -343,7 +341,7 @@ DigitList::fitsIntoLong(UBool ignoreNegativeZero)
* a long.
*/
UBool
DigitList::fitsIntoInt64(UBool ignoreNegativeZero)
DigitList::fitsIntoInt64(UBool ignoreNegativeZero) /*const*/
{
// Figure out if the result will fit in a long. We have to
// first look for nonzero digits after the decimal point;
@ -360,8 +358,6 @@ DigitList::fitsIntoInt64(UBool ignoreNegativeZero)
return fIsPositive || ignoreNegativeZero;
}
// initializeLONG_MIN_REP();
// If the digit list represents a double or this number is too
// big for a long.
if (fDecimalAt < fCount || fDecimalAt > I64_MIN_REP_LENGTH)
@ -561,7 +557,7 @@ DigitList::round(int32_t maximumDigits)
* @return true if digit <code>maximumDigits-1</code> should be
* incremented
*/
UBool DigitList::shouldRoundUp(int32_t maximumDigits) {
UBool DigitList::shouldRoundUp(int32_t maximumDigits) const {
// Implement IEEE half-even rounding
if (fDigits[maximumDigits] == '5' ) {
for (int i=maximumDigits+1; i<fCount; ++i) {
@ -640,46 +636,6 @@ DigitList::isZero() const
return TRUE;
}
/**
* We represent LONG_MIN internally as LONG_MAX + 1. This is actually an impossible
* value, for positive long integers, so we are safe in doing so.
*/
/* // This code is unused.
UBool
DigitList::isLONG_MIN() const
{
// initializeLONG_MIN_REP();
if (fCount != LONG_MIN_REP_LENGTH)
return FALSE;
for (int32_t i = 0; i < LONG_MIN_REP_LENGTH; ++i)
{
if (fDigits[i] != LONG_MIN_REP[i+1])
return FALSE;
}
return TRUE;
}
*/
// Initialize the LONG_MIN representation buffer. Note that LONG_MIN
// is stored as LONG_MAX+1 (LONG_MIN without the negative sign).
/*void
DigitList::initializeLONG_MIN_REP()
{
if (LONG_MIN_REP_LENGTH == 0)
{
char buf[LONG_DIGITS];
sprintf(buf, "%d", INT32_MIN);
LONG_MIN_REP_LENGTH = strlen(buf) - 1;
// assert(LONG_MIN_REP_LENGTH == LONG_DIGITS);
for (int32_t i=1; i<=LONG_MIN_REP_LENGTH; ++i)
LONG_MIN_REP[i-1] = buf[i];
}
}*/
U_NAMESPACE_END
//eof

View file

@ -118,7 +118,7 @@ public:
* Returns 0.0 if zero length.
* @return the value of the digit list.
*/
double getDouble(void);
double getDouble(void) /*const*/;
/**
* Utility routine to get the value of the digit list
@ -126,7 +126,7 @@ public:
* Returns 0 if zero length.
* @return the value of the digit list, return 0 if it is zero length
*/
int32_t getLong(void);
int32_t getLong(void) /*const*/;
/**
* Utility routine to get the value of the digit list
@ -134,7 +134,7 @@ public:
* Returns 0 if zero length.
* @return the value of the digit list, return 0 if it is zero length
*/
int64_t getInt64(void);
int64_t getInt64(void) /*const*/;
/**
* Return true if the number represented by this object can fit into
@ -143,7 +143,7 @@ public:
* @return true if the number represented by this object can fit into
* a long, return false otherwise.
*/
UBool fitsIntoLong(UBool ignoreNegativeZero);
UBool fitsIntoLong(UBool ignoreNegativeZero) /*const*/;
/**
* Return true if the number represented by this object can fit into
@ -152,7 +152,7 @@ public:
* @return true if the number represented by this object can fit into
* a long, return false otherwise.
*/
UBool fitsIntoInt64(UBool ignoreNegativeZero);
UBool fitsIntoInt64(UBool ignoreNegativeZero) /*const*/;
/**
* Utility routine to set the value of the digit list from a double
@ -235,13 +235,7 @@ private:
*/
void round(int32_t maximumDigits);
/**
* Initializes the buffer that records the mimimum long value.
* @param maximumDigits The maximum number of digits to be shown.
*/
/*static void initializeLONG_MIN_REP(void);*/
UBool shouldRoundUp(int32_t maximumDigits);
UBool shouldRoundUp(int32_t maximumDigits) const;
};
// -------------------------------------