Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

DigitList Class Reference

Digit List. More...

#include <digitlst.h>

List of all members.

Public Methods

 DigitList ()
 ~DigitList ()
 DigitList (const DigitList&)
DigitList& operator= (const DigitList&)
UBool operator== (const DigitList& other) const
 Return true if another object is semantically equal to this one.

UBool operator!= (const DigitList& other) const
 Return true if another object is semantically unequal to this one. More...

void clear (void)
 Clears out the digits. More...

void append (char digit)
 Appends digits to the list. More...

double getDouble (void)
 Utility routine to get the value of the digit list Returns 0.0 if zero length.

int32_t getLong (void)
 Utility routine to get the value of the digit list Make sure that fitsIntoLong() is called before calling this function. More...

UBool fitsIntoLong (UBool ignoreNegativeZero)
 Return true if the number represented by this object can fit into a long.

void set (double source, int32_t maximumDigits, UBool fixedPoint = TRUE)
 Utility routine to set the value of the digit list from a double Input must be non-negative, and must not be Inf, -Inf, or NaN. More...

void set (int32_t source, int32_t maximumDigits = 0)
 Utility routine to set the value of the digit list from a long. More...

UBool isZero (void) const
 Return true if this is a representation of zero.

UBool isLONG_MIN (void) const
 Return true if this is a representation of LONG_MIN. More...


Public Attributes

int32_t fDecimalAt
 These data members are intentionally public and can be set directly. More...

int32_t fCount
UBool fIsPositive
char* fDigits

Static Public Attributes

const char kZero
 This is the zero digit. More...


Detailed Description

Digit List.

Private to DecimalFormat. Handles the transcoding between numeric values and strings of characters. Only handles non-negative numbers. The division of labor between DigitList and DecimalFormat is that DigitList handles the radix 10 representation issues; DecimalFormat handles the locale-specific issues such as positive/negative, grouping, decimal point, currency, and so on.

A DigitList is really a representation of a floating point value. It may be an integer value; we assume that a double has sufficient precision to represent all digits of a long.

The DigitList representation consists of a string of characters, which are the digits radix 10, from '0' to '9'. It also has a radix 10 exponent associated with it. The value represented by a DigitList object can be computed by mulitplying the fraction f, where 0 <= f < 1, derived by placing all the digits of the list to the right of the decimal point, by 10^exponent.

Definition at line 52 of file digitlst.h.


Constructor & Destructor Documentation

DigitList::DigitList ( )
 

DigitList::~DigitList ( )
 

DigitList::DigitList ( const DigitList & )
 


Member Function Documentation

void DigitList::append ( char digit ) [inline]
 

Appends digits to the list.

Ignores all digits beyond the first DBL_DIG, since they are not significant for either longs or doubles.

Definition at line 213 of file digitlst.h.

void DigitList::clear ( void )
 

Clears out the digits.

Use before appending them. Typically, you set a series of digits with append, then at the point you hit the decimal point, you set myDigitList.fDecimalAt = myDigitList.fCount; then go on appending digits.

UBool DigitList::fitsIntoLong ( UBool ignoreNegativeZero )
 

Return true if the number represented by this object can fit into a long.

double DigitList::getDouble ( void )
 

Utility routine to get the value of the digit list Returns 0.0 if zero length.

int32_t DigitList::getLong ( void )
 

Utility routine to get the value of the digit list Make sure that fitsIntoLong() is called before calling this function.

Returns 0 if zero length.

UBool DigitList::isLONG_MIN ( void ) const
 

Return true if this is a representation of LONG_MIN.

You must use this method to determine if this is so; you cannot check directly, because a special format is used to handle this.

UBool DigitList::isZero ( void ) const
 

Return true if this is a representation of zero.

UBool DigitList::operator!= ( const DigitList & other ) const [inline]
 

Return true if another object is semantically unequal to this one.

Definition at line 69 of file digitlst.h.

DigitList& DigitList::operator= ( const DigitList & )
 

UBool DigitList::operator== ( const DigitList & other ) const
 

Return true if another object is semantically equal to this one.

Referenced by operator!=().

void DigitList::set ( int32_t source,
int32_t maximumDigits = 0 )
 

Utility routine to set the value of the digit list from a long.

If a non-zero maximumDigits is specified, no more than that number of significant digits will be produced.

void DigitList::set ( double source,
int32_t maximumDigits,
UBool fixedPoint = TRUE )
 

Utility routine to set the value of the digit list from a double Input must be non-negative, and must not be Inf, -Inf, or NaN.

The maximum fraction digits helps us round properly.


Member Data Documentation

int32_t DigitList::fCount
 

Definition at line 170 of file digitlst.h.

int32_t DigitList::fDecimalAt
 

These data members are intentionally public and can be set directly.

The value represented is given by placing the decimal point before fDigits[fDecimalAt]. If fDecimalAt is < 0, then leading zeros between the decimal point and the first nonzero digit are implied. If fDecimalAt is > fCount, then trailing zeros between the fDigits[fCount-1] and the decimal point are implied.

Equivalently, the represented value is given by f * 10^fDecimalAt. Here f is a value 0.1 <= f < 1 arrived at by placing the digits in fDigits to the right of the decimal.

DigitList is normalized, so if it is non-zero, fDigits[0] is non-zero. We don't allow denormalized numbers because our exponent is effectively of unlimited magnitude. The fCount value contains the number of significant digits present in fDigits[].

Zero is represented by any DigitList with fCount == 0 or with each fDigits[i] for all i <= fCount == '0'.

Definition at line 169 of file digitlst.h.

char * DigitList::fDigits
 

Definition at line 172 of file digitlst.h.

UBool DigitList::fIsPositive
 

Definition at line 171 of file digitlst.h.

const char DigitList::kZero [static]
 

This is the zero digit.

Array elements fDigits[i] have values from kZero to kZero + 9. Typically, this is '0'.

Definition at line 135 of file digitlst.h.


The documentation for this class was generated from the following file:
Generated at Tue Dec 5 17:56:06 2000 for ICU by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000