#ifndef NUMBER_H #define NUMBER_H #include #include "packedintarray.h" class Number { public: Number( int iScale=0, int iRadix=10 ); Number( const Bu::String &sData, int iScale=0, int iRadix=10 ); virtual ~Number(); Number &operator=( const Bu::String &sNum ); Number &operator=( const Number &rhs ); Number &operator=( const int32_t iNum ); Number operator+( const Number &rhs ) const; Number operator-( const Number &rhs ) const; Number operator*( const Number &rhs ) const; Number operator/( const Number &rhs ) const; Number operator%( const Number &rhs ) const; Number operator-() const; bool operator==( const Bu::String &rhs ) const; bool operator==( const Number &rhs ) const; bool operator!=( const Number &rhs ) const; bool operator>( const Number &rhs ) const; bool operator<( const Number &rhs ) const; bool operator>=( const Number &rhs ) const; bool operator<=( const Number &rhs ) const; void set( const Bu::String &sNum ); void set( const Number &sNum ); void set( int32_t iNum ); void divide( const Number &rhs, Number &q, Number &r ) const; bool isZero() const; operator Bu::String() const { return aInt.toString(); } Bu::String toString() const; int digit( int iIdx ) const; void setDigit( int iIdx, int iVal ); int getScale() const { return iScale; } int getEffectiveScale() const; void setScale( int iNewScale ); int getIntegralDigits() const { return aInt.getSize(); } int32_t toInt32() const; Number toRadix( int iNewRadix, int iNewScale=-1 ) const; private: Number add( const Number &rhs, bool bSub ) const; private: int iRadix; int iScale; bool bPositive; PackedIntArray aInt; PackedIntArray aFrac; }; Bu::Formatter &operator<<( Bu::Formatter &f, const Number &n ); #endif