#include <common/i_integer.h>
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). |
|
create an IInteger with indeterminate value.
|
|
|
|
|
|
|
|
Create an IInteger from various types.
|
Copy constructor.
|
Convert an ascii string to a value.
initial_string | string to convert |
base | base to use. Must be in range 1 to 36 |
|
|
|
Retrieve the value as a char - requires is_c_char.
|
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
|
Retrieve the value as an int - requires is_c_int.
|
Retrieve the value as a long - requires is_c_long.
|
Retrieve the value as a short - requires is_c_short.
|
Retrieve the value as a signed char - requires is_signed_c_char.
|
Retrieve the value as a size_t - requires is_c_size_t.
|
|
Retrieve the value as an unsigned char - requires is_unsigned_c_char.
|
Retrieve the value as an unsigned int - requires is_c_unsigned_int.
|
Retrieve the value as an unsigned long - requires is_c_unsigned_long.
|
Retrieve the value as an unsigned short - requires is_unsigned_c_short.
|
Set the value to undetermined.
|
|
Return a negative infinity.
|
Return a positive infinity.
|
Return a signless infinity (not the same as positive infinity).
|
restrict the iinteger to a finite bit size use 2's complement to resolve overflows infinities and undetermined will return themselves.
|
|
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.
|
Will the value fit in a char.
|
Will the value fit in an int.
|
Will the value fit in a long.
|
Will the value fit in a short.
|
Will the value fit in a signed char.
|
Will the value fit in a size_t.
|
Is the integer a string int.
|
Will the value fit in an unsigned char.
|
Will the value fit in an unsigned int.
|
Will the value fit in an unsigned long.
|
Will the value fit in an unsigned short.
|
|
Is the iinteger finite?
|
Is the iinteger negative?
|
Is the iinteger unsigned infinity? NOTE: There are three infinities, Inf (signless) +Inf and -Inf (signed).
|
Is the iinteger indeterminate?
|
|
|
|
Bitwise and.
|
logical and.
|
|
multiply.
|
|
logical not.
|
|
|
|
|
|
remainder.
|
|
|
add.
|
|
|
|
|
subtract.
|
|
|
|
divide.
|
|
|
|
|
|
|
left shift.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
right shift.
|
|
Bitwise exclusive or.
|
|
Bitwise or.
|
|
logical or.
|
Bitwise negate.
|
Appears to duplicate write, but this is not clear - avoid.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Output to a char string.
This is allocated from the heap - the caller is responsible for its deletion.
|
|
|
Write the value to an ostring.
|
The old way to write directly to a previously allocated char *.