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

IInteger Class Reference

provides an infinite size integer class as well as undetermined and signless and signed infinity values. More...

#include <common/i_integer.h>

List of all members.

Public Methods

 IInteger (void)
 create an IInteger with indeterminate value.

 IInteger (signed char initial_value)
 IInteger (unsigned char initial_value)
 IInteger (short initial_value)
 IInteger (unsigned short initial_value)
 IInteger (int initial_value)
 IInteger (unsigned int initial_value)
 IInteger (long initial_value)
 IInteger (unsigned long initial_value)
 Create an IInteger from various types.

 IInteger (const IInteger &initial_value)
 Copy constructor.

 IInteger (const char *initial_string, int base = 10)
 Convert an ascii string to a value. More...

 ~IInteger ()
bool is_undetermined (void) const
 Is the iinteger indeterminate?

bool is_signless_infinity (void) const
 Is the iinteger unsigned infinity? NOTE: There are three infinities, Inf (signless) +Inf and -Inf (signed).

bool is_finite (void) const
 Is the iinteger finite?

bool is_negative (void) const
 Is the iinteger negative?

bool is_c_string_int (void) const
 Is the integer a string int.

bool is_c_char (void) const
 Will the value fit in a char.

bool is_c_unsigned_char (void) const
 Will the value fit in an unsigned char.

bool is_c_signed_char (void) const
 Will the value fit in a signed char.

bool is_c_short (void) const
 Will the value fit in a short.

bool is_c_unsigned_short (void) const
 Will the value fit in an unsigned short.

bool is_c_int (void) const
 Will the value fit in an int.

bool is_c_unsigned_int (void) const
 Will the value fit in an unsigned int.

bool is_c_long (void) const
 Will the value fit in a long.

bool is_c_unsigned_long (void) const
 Will the value fit in an unsigned long.

bool is_c_size_t (void) const
 Will the value fit in a size_t.

char* c_string_int (void) const
 Retrieve value as a string - requires is_c_string. More...

char c_char (void) const
 Retrieve the value as a char - requires is_c_char.

unsigned char c_unsigned_char (void) const
 Retrieve the value as an unsigned char - requires is_unsigned_c_char.

signed char c_signed_char (void) const
 Retrieve the value as a signed char - requires is_signed_c_char.

short c_short (void) const
 Retrieve the value as a short - requires is_c_short.

unsigned short c_unsigned_short (void) const
 Retrieve the value as an unsigned short - requires is_unsigned_c_short.

int c_int (void) const
 Retrieve the value as an int - requires is_c_int.

unsigned int c_unsigned_int (void) const
 Retrieve the value as an unsigned int - requires is_c_unsigned_int.

long c_long (void) const
 Retrieve the value as a long - requires is_c_long.

unsigned long c_unsigned_long (void) const
 Retrieve the value as an unsigned long - requires is_c_unsigned_long.

size_t c_size_t (void) const
 Retrieve the value as a size_t - requires is_c_size_t.

double c_double (void) const
 Retrieve the value as a double. More...

void set_c_char (char new_value)
void set_c_unsigned_char (unsigned char new_value)
void set_c_signed_char (signed char new_value)
void set_c_short (short new_value)
void set_c_unsigned_short (unsigned short new_value)
void set_c_int (int new_value)
void set_c_unsigned_int (unsigned int new_value)
void set_c_long (long new_value)
void set_c_unsigned_long (unsigned long new_value)
void set_c_size_t (size_t new_value)
void set_integer (const IInteger &new_value)
void clear (void)
 Set the value to undetermined.

void write (ostream *out, int base = 10) const
 Write the value to an ostring.

void write (String &str, int base) const
String to_String (int base = 10) const
void read (const char *location, int base = 10)
void read (istream *in, int base = 10)
IInteger written_length (int base = 10) const
 The old way to write directly to a previously allocated char *. More...

void write (char *location, int base = 10) const
char* to_string (int base = 10) const
 Output to a char string. More...

void print (ostream *in, int base = 10) const
 Appears to duplicate write, but this is not clear - avoid.

bool is_divisible_by (const IInteger &other) const
IInteger add (const IInteger &other) const
IInteger subtract (const IInteger &other) const
IInteger multiply (const IInteger &other) const
IInteger div (const IInteger &other) const
IInteger mod (const IInteger &other) const
IInteger negate (void) const
IInteger& operator= (const IInteger &other)
bool operator== (const IInteger &other) const
bool operator!= (const IInteger &other) const
bool operator< (const IInteger &other) const
bool operator> (const IInteger &other) const
bool operator<= (const IInteger &other) const
bool operator>= (const IInteger &other) const
bool operator== (int other) const
bool operator!= (int other) const
bool operator< (int other) const
bool operator> (int other) const
bool operator<= (int other) const
bool operator>= (int other) const
bool operator== (unsigned int other) const
bool operator!= (unsigned int other) const
bool operator< (unsigned int other) const
bool operator> (unsigned int other) const
bool operator<= (unsigned int other) const
bool operator>= (unsigned int other) const
bool operator== (long other) const
bool operator!= (long other) const
bool operator< (long other) const
bool operator> (long other) const
bool operator<= (long other) const
bool operator>= (long other) const
bool operator== (unsigned long other) const
bool operator!= (unsigned long other) const
bool operator< (unsigned long other) const
bool operator> (unsigned long other) const
bool operator<= (unsigned long other) const
bool operator>= (unsigned long other) const
IInteger operator+ (const IInteger &other) const
 add.

IInteger operator- (const IInteger &other) const
 subtract.

IInteger operator * (const IInteger &other) const
 multiply.

IInteger operator/ (const IInteger &other) const
 divide.

IInteger operator% (const IInteger &other) const
 remainder.

IInteger operator^ (const IInteger &other) const
 Bitwise exclusive or.

IInteger operator & (const IInteger &other) const
 Bitwise and.

IInteger operator| (const IInteger &other) const
 Bitwise or.

IInteger operator~ (void) const
 Bitwise negate.

IInteger operator<< (const IInteger &other) const
 left shift.

IInteger operator>> (const IInteger &other) const
 right shift.

bool operator! (void) const
 logical not.

bool operator && (const IInteger &other) const
 logical and.

bool operator|| (const IInteger &other) const
 logical or.

IInteger operator+ (void) const
IInteger operator- (void) const
IInteger& operator+= (const IInteger &other)
IInteger& operator-= (const IInteger &other)
IInteger& operator *= (const IInteger &other)
IInteger& operator/= (const IInteger &other)
IInteger& operator%= (const IInteger &other)
IInteger& operator^= (const IInteger &other)
IInteger& operator &= (const IInteger &other)
IInteger& operator|= (const IInteger &other)
IInteger& operator>>= (const IInteger &other)
IInteger& operator<<= (const IInteger &other)
IInteger& operator++ (void)
IInteger& operator-- (void)
IInteger operator++ (int)
IInteger operator-- (int)

Static Public Methods

IInteger ii_gcd (const IInteger &op1, const IInteger &op2)
 The following two static functions return the GCD (Greatest Common Denominator) of op1 and op2. More...

IInteger ii_gcd (const IInteger &op1, const IInteger &op2, IInteger *coeff1, IInteger *coeff2)
IInteger ii_finite_size (const IInteger &ii, const IInteger &bit_size, bool is_signed)
 restrict the iinteger to a finite bit size use 2's complement to resolve overflows infinities and undetermined will return themselves.

IInteger i_positive_inf (void)
 Return a positive infinity.

IInteger i_negative_inf (void)
 Return a negative infinity.

IInteger i_signless_inf (void)
 Return a signless infinity (not the same as positive infinity).


Detailed Description

provides an infinite size integer class as well as undetermined and signless and signed infinity values.


Constructor & Destructor Documentation

IInteger::IInteger ( void)

create an IInteger with indeterminate value.

IInteger::IInteger ( signed char initial_value)

IInteger::IInteger ( unsigned char initial_value)

IInteger::IInteger ( short initial_value)

IInteger::IInteger ( unsigned short initial_value)

IInteger::IInteger ( int initial_value)

IInteger::IInteger ( unsigned int initial_value)

IInteger::IInteger ( long initial_value)

IInteger::IInteger ( unsigned long initial_value)

Create an IInteger from various types.

IInteger::IInteger ( const IInteger & initial_value)

Copy constructor.

IInteger::IInteger ( const char * initial_string,
int base = 10)

Convert an ascii string to a value.

Parameters:
initial_string   string to convert
base   base to use. Must be in range 1 to 36
NOTE:
No prefix (such as 0x for hex) should be present.
As well as numeric values, the values ?? (indeterminate
+Inf -Inf and Inf are recognized

IInteger::~IInteger ()


Member Function Documentation

IInteger IInteger::add ( const IInteger & other) const

char IInteger::c_char ( void) const

Retrieve the value as a char - requires is_c_char.

double IInteger::c_double ( void) const

Retrieve the value as a double.

Any non-indeterminate non-infinite value can be returned as a double (unless it is enormously large) but precision will be lost if it larger than about 10^16

int IInteger::c_int ( void) const

Retrieve the value as an int - requires is_c_int.

long IInteger::c_long ( void) const

Retrieve the value as a long - requires is_c_long.

short IInteger::c_short ( void) const

Retrieve the value as a short - requires is_c_short.

signed char IInteger::c_signed_char ( void) const

Retrieve the value as a signed char - requires is_signed_c_char.

size_t IInteger::c_size_t ( void) const

Retrieve the value as a size_t - requires is_c_size_t.

char * IInteger::c_string_int ( void) const

Retrieve value as a string - requires is_c_string.

See also:
{to_String()}

unsigned char IInteger::c_unsigned_char ( void) const

Retrieve the value as an unsigned char - requires is_unsigned_c_char.

unsigned int IInteger::c_unsigned_int ( void) const

Retrieve the value as an unsigned int - requires is_c_unsigned_int.

unsigned long IInteger::c_unsigned_long ( void) const

Retrieve the value as an unsigned long - requires is_c_unsigned_long.

unsigned short IInteger::c_unsigned_short ( void) const

Retrieve the value as an unsigned short - requires is_unsigned_c_short.

void IInteger::clear ( void)

Set the value to undetermined.

IInteger IInteger::div ( const IInteger & other) const

IInteger IInteger::i_negative_inf ( void) [static]

Return a negative infinity.

IInteger IInteger::i_positive_inf ( void) [static]

Return a positive infinity.

IInteger IInteger::i_signless_inf ( void) [static]

Return a signless infinity (not the same as positive infinity).

IInteger IInteger::ii_finite_size ( const IInteger & ii,
const IInteger & bit_size,
bool is_signed) [static]

restrict the iinteger to a finite bit size use 2's complement to resolve overflows infinities and undetermined will return themselves.

IInteger IInteger::ii_gcd ( const IInteger & op1,
const IInteger & op2,
IInteger * coeff1,
IInteger * coeff2) [static]

IInteger IInteger::ii_gcd ( const IInteger & op1,
const IInteger & op2) [static]

The following two static functions return the GCD (Greatest Common Denominator) of op1 and op2.

In addition, the second form sets *coeff1 and *coeff2 to values such that

(op1 * (*coeff1)) + (op2 * (*coeff2)) = GCD.

These coefficients can be extracted by the same algorithm that finds the GCD.

bool IInteger::is_c_char ( void) const

Will the value fit in a char.

bool IInteger::is_c_int ( void) const

Will the value fit in an int.

bool IInteger::is_c_long ( void) const

Will the value fit in a long.

bool IInteger::is_c_short ( void) const

Will the value fit in a short.

bool IInteger::is_c_signed_char ( void) const

Will the value fit in a signed char.

bool IInteger::is_c_size_t ( void) const

Will the value fit in a size_t.

bool IInteger::is_c_string_int ( void) const

Is the integer a string int.

bool IInteger::is_c_unsigned_char ( void) const

Will the value fit in an unsigned char.

bool IInteger::is_c_unsigned_int ( void) const

Will the value fit in an unsigned int.

bool IInteger::is_c_unsigned_long ( void) const

Will the value fit in an unsigned long.

bool IInteger::is_c_unsigned_short ( void) const

Will the value fit in an unsigned short.

bool IInteger::is_divisible_by ( const IInteger & other) const

bool IInteger::is_finite ( void) const

Is the iinteger finite?

bool IInteger::is_negative ( void) const

Is the iinteger negative?

bool IInteger::is_signless_infinity ( void) const

Is the iinteger unsigned infinity? NOTE: There are three infinities, Inf (signless) +Inf and -Inf (signed).

bool IInteger::is_undetermined ( void) const

Is the iinteger indeterminate?

IInteger IInteger::mod ( const IInteger & other) const

IInteger IInteger::multiply ( const IInteger & other) const

IInteger IInteger::negate ( void) const

IInteger IInteger::operator & ( const IInteger & other) const

Bitwise and.

bool IInteger::operator && ( const IInteger & other) const

logical and.

IInteger & IInteger::operator &= ( const IInteger & other)

IInteger IInteger::operator * ( const IInteger & other) const

multiply.

IInteger & IInteger::operator *= ( const IInteger & other)

bool IInteger::operator! ( void) const

logical not.

bool IInteger::operator!= ( unsigned long other) const

bool IInteger::operator!= ( long other) const

bool IInteger::operator!= ( unsigned int other) const

bool IInteger::operator!= ( int other) const

bool IInteger::operator!= ( const IInteger & other) const

IInteger IInteger::operator% ( const IInteger & other) const

remainder.

IInteger & IInteger::operator%= ( const IInteger & other)

IInteger IInteger::operator+ ( void) const

IInteger IInteger::operator+ ( const IInteger & other) const

add.

IInteger IInteger::operator++ ( int)

IInteger & IInteger::operator++ ( void)

IInteger & IInteger::operator+= ( const IInteger & other)

IInteger IInteger::operator- ( void) const

IInteger IInteger::operator- ( const IInteger & other) const

subtract.

IInteger IInteger::operator-- ( int)

IInteger & IInteger::operator-- ( void)

IInteger & IInteger::operator-= ( const IInteger & other)

IInteger IInteger::operator/ ( const IInteger & other) const

divide.

IInteger & IInteger::operator/= ( const IInteger & other)

bool IInteger::operator< ( unsigned long other) const

bool IInteger::operator< ( long other) const

bool IInteger::operator< ( unsigned int other) const

bool IInteger::operator< ( int other) const

bool IInteger::operator< ( const IInteger & other) const

IInteger IInteger::operator<< ( const IInteger & other) const

left shift.

IInteger & IInteger::operator<<= ( const IInteger & other)

bool IInteger::operator<= ( unsigned long other) const

bool IInteger::operator<= ( long other) const

bool IInteger::operator<= ( unsigned int other) const

bool IInteger::operator<= ( int other) const

bool IInteger::operator<= ( const IInteger & other) const

IInteger & IInteger::operator= ( const IInteger & other)

bool IInteger::operator== ( unsigned long other) const

bool IInteger::operator== ( long other) const

bool IInteger::operator== ( unsigned int other) const

bool IInteger::operator== ( int other) const

bool IInteger::operator== ( const IInteger & other) const

bool IInteger::operator> ( unsigned long other) const

bool IInteger::operator> ( long other) const

bool IInteger::operator> ( unsigned int other) const

bool IInteger::operator> ( int other) const

bool IInteger::operator> ( const IInteger & other) const

bool IInteger::operator>= ( unsigned long other) const

bool IInteger::operator>= ( long other) const

bool IInteger::operator>= ( unsigned int other) const

bool IInteger::operator>= ( int other) const

bool IInteger::operator>= ( const IInteger & other) const

IInteger IInteger::operator>> ( const IInteger & other) const

right shift.

IInteger & IInteger::operator>>= ( const IInteger & other)

IInteger IInteger::operator^ ( const IInteger & other) const

Bitwise exclusive or.

IInteger & IInteger::operator^= ( const IInteger & other)

IInteger IInteger::operator| ( const IInteger & other) const

Bitwise or.

IInteger & IInteger::operator|= ( const IInteger & other)

bool IInteger::operator|| ( const IInteger & other) const

logical or.

IInteger IInteger::operator~ ( void) const

Bitwise negate.

void IInteger::print ( ostream * in,
int base = 10) const

Appears to duplicate write, but this is not clear - avoid.

void IInteger::read ( istream * in,
int base = 10)

void IInteger::read ( const char * location,
int base = 10)

void IInteger::set_c_char ( char new_value)

void IInteger::set_c_int ( int new_value)

void IInteger::set_c_long ( long new_value)

void IInteger::set_c_short ( short new_value)

void IInteger::set_c_signed_char ( signed char new_value)

void IInteger::set_c_size_t ( size_t new_value)

void IInteger::set_c_unsigned_char ( unsigned char new_value)

void IInteger::set_c_unsigned_int ( unsigned int new_value)

void IInteger::set_c_unsigned_long ( unsigned long new_value)

void IInteger::set_c_unsigned_short ( unsigned short new_value)

void IInteger::set_integer ( const IInteger & new_value)

IInteger IInteger::subtract ( const IInteger & other) const

String IInteger::to_String ( int base = 10) const

char * IInteger::to_string ( int base = 10) const

Output to a char string.

This is allocated from the heap - the caller is responsible for its deletion.

use to_String for new code

void IInteger::write ( char * location,
int base = 10) const

void IInteger::write ( String & str,
int base) const

void IInteger::write ( ostream * out,
int base = 10) const

Write the value to an ostring.

IInteger IInteger::written_length ( int base = 10) const

The old way to write directly to a previously allocated char *.

Prefer to_string for new code

The documentation for this class was generated from the following files:
Generated at Mon Jul 31 13:43:15 2000 for NCI SUIF by doxygen 1.1.2 written by Dimitri van Heesch, © 1997-2000