All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Friends | List of all members
ttmath::Int< value_size > Class Template Reference

Int implements a big integer value with a sign. More...

#include <ttmathint.h>

Public Member Functions

void SetMax ()
 
void SetMin ()
 
void SetSignOne ()
 
uint ChangeSign ()
 
void SetSign ()
 
bool IsSign () const
 
uint Abs ()
 
uint Add (const Int< value_size > &ss2)
 
uint AddInt (uint value, uint index=0)
 
uint AddTwoInts (uint x2, uint x1, uint index)
 
uint Sub (const Int< value_size > &ss2)
 
uint SubInt (uint value, uint index=0)
 
uint AddOne ()
 
uint SubOne ()
 
uint MulInt (sint ss2)
 
uint Mul (Int< value_size > ss2)
 
uint Div (Int< value_size > ss2, Int< value_size > *remainder=0)
 
uint Div (const Int< value_size > &ss2, Int< value_size > &remainder)
 
uint DivInt (sint ss2, sint *remainder=0)
 
uint DivInt (sint ss2, sint &remainder)
 
uint Pow (Int< value_size > pow)
 
template<uint argument_size>
uint FromInt (const Int< argument_size > &p)
 
uint FromInt (sint value)
 
template<uint argument_size>
uint FromUInt (const UInt< argument_size > &p)
 
template<uint argument_size>
uint FromInt (const UInt< argument_size > &p)
 
uint FromUInt (uint value)
 
uint FromInt (uint value)
 
Int< value_size > & operator= (const Int< value_size > &p)
 
template<uint argument_size>
Int< value_size > & operator= (const Int< argument_size > &p)
 
Int< value_size > & operator= (sint i)
 
 Int (sint i)
 
 Int (const Int< value_size > &u)
 
template<uint argument_size>
 Int (const Int< argument_size > &u)
 
template<uint argument_size>
Int< value_size > & operator= (const UInt< argument_size > &p)
 
Int< value_size > & operator= (uint i)
 
 Int (uint i)
 
template<uint argument_size>
 Int (const UInt< argument_size > &u)
 
uint FromUInt (ulint n)
 
uint FromInt (ulint n)
 
uint FromInt (slint n)
 
Int< value_size > & operator= (ulint n)
 
 Int (ulint n)
 
Int< value_size > & operator= (slint n)
 
 Int (slint n)
 
 Int (const char *s)
 
 Int (const std::string &s)
 
 Int (const wchar_t *s)
 
 Int (const std::wstring &s)
 
 Int ()
 
 ~Int ()
 
sint ToInt () const
 
uint ToUInt (uint &result) const
 
uint ToInt (uint &result) const
 
uint ToInt (sint &result) const
 
uint ToUInt (ulint &result) const
 
uint ToInt (ulint &result) const
 
uint ToInt (slint &result) const
 
void ToString (std::string &result, uint b=10) const
 
std::string ToString (uint b=10) const
 
void ToString (std::wstring &result, uint b=10) const
 
std::wstring ToWString (uint b=10) const
 
uint FromString (const char *s, uint b=10, const char **after_source=0, bool *value_read=0)
 
uint FromString (const wchar_t *s, uint b=10, const wchar_t **after_source=0, bool *value_read=0)
 
uint FromString (const std::string &s, uint b=10)
 
Int< value_size > & operator= (const char *s)
 
uint FromString (const std::wstring &s, uint b=10)
 
Int< value_size > & operator= (const wchar_t *s)
 
Int< value_size > & operator= (const std::wstring &s)
 
Int< value_size > & operator= (const std::string &s)
 
bool operator== (const Int< value_size > &l) const
 
bool operator!= (const Int< value_size > &l) const
 
bool operator< (const Int< value_size > &l) const
 
bool operator> (const Int< value_size > &l) const
 
bool operator<= (const Int< value_size > &l) const
 
bool operator>= (const Int< value_size > &l) const
 
Int< value_size > operator- () const
 
Int< value_size > operator- (const Int< value_size > &p2) const
 
Int< value_size > & operator-= (const Int< value_size > &p2)
 
Int< value_size > operator+ (const Int< value_size > &p2) const
 
Int< value_size > & operator+= (const Int< value_size > &p2)
 
Int< value_size > operator* (const Int< value_size > &p2) const
 
Int< value_size > & operator*= (const Int< value_size > &p2)
 
Int< value_size > operator/ (const Int< value_size > &p2) const
 
Int< value_size > & operator/= (const Int< value_size > &p2)
 
Int< value_size > operator% (const Int< value_size > &p2) const
 
Int< value_size > & operator%= (const Int< value_size > &p2)
 
UInt< value_size > & operator++ ()
 
UInt< value_size > operator++ (int)
 
UInt< value_size > & operator-- ()
 
UInt< value_size > operator-- (int)
 
- Public Member Functions inherited from ttmath::UInt< value_size >
template<class ostream_type >
void PrintTable (ostream_type &output) const
 
template<class char_type , class ostream_type >
void PrintLog (const char_type *msg, ostream_type &output) const
 
template<class char_type , class ostream_type >
void PrintLog (const char_type *msg, uint carry, ostream_type &output) const
 
uint Size () const
 
void SetZero ()
 
void SetOne ()
 
void SetMax ()
 
void SetMin ()
 
void Swap (UInt< value_size > &ss2)
 
void SetFromTable (const uint *temp_table, uint temp_table_len)
 
uint AddOne ()
 
uint SubOne ()
 
uint Rcl (uint bits, uint c=0)
 
uint Rcr (uint bits, uint c=0)
 
uint CompensationToLeft ()
 
bool FindLeadingBit (uint &table_id, uint &index) const
 
bool FindLowestBit (uint &table_id, uint &index) const
 
uint GetBit (uint bit_index) const
 
uint SetBit (uint bit_index)
 
void BitAnd (const UInt< value_size > &ss2)
 
void BitOr (const UInt< value_size > &ss2)
 
void BitXor (const UInt< value_size > &ss2)
 
void BitNot ()
 
void BitNot2 ()
 
uint MulInt (uint ss2)
 
template<uint result_size>
void MulInt (uint ss2, UInt< result_size > &result) const
 
uint Mul (const UInt< value_size > &ss2, uint algorithm=100)
 
void MulBig (const UInt< value_size > &ss2, UInt< value_size *2 > &result, uint algorithm=100)
 
uint Mul1 (const UInt< value_size > &ss2)
 
void Mul1Big (const UInt< value_size > &ss2_, UInt< value_size *2 > &result)
 
uint Mul2 (const UInt< value_size > &ss2)
 
void Mul2Big (const UInt< value_size > &ss2, UInt< value_size *2 > &result)
 
uint Mul3 (const UInt< value_size > &ss2)
 
void Mul3Big (const UInt< value_size > &ss2, UInt< value_size *2 > &result)
 
uint MulFastest (const UInt< value_size > &ss2)
 
void MulFastestBig (const UInt< value_size > &ss2, UInt< value_size *2 > &result)
 
uint DivInt (uint divisor, uint *remainder=0)
 
uint DivInt (uint divisor, uint &remainder)
 
uint Div (const UInt< value_size > &divisor, UInt< value_size > *remainder=0, uint algorithm=3)
 
uint Div (const UInt< value_size > &divisor, UInt< value_size > &remainder, uint algorithm=3)
 
uint Div1 (const UInt< value_size > &divisor, UInt< value_size > *remainder=0)
 
uint Div1 (const UInt< value_size > &divisor, UInt< value_size > &remainder)
 
uint Div2 (const UInt< value_size > &divisor, UInt< value_size > *remainder=0)
 
uint Div2 (const UInt< value_size > &divisor, UInt< value_size > &remainder)
 
uint Div3 (const UInt< value_size > &ss2, UInt< value_size > *remainder=0)
 
uint Div3 (const UInt< value_size > &ss2, UInt< value_size > &remainder)
 
uint Pow (UInt< value_size > pow)
 
void Sqrt ()
 
void ClearFirstBits (uint n)
 
bool IsTheHighestBitSet () const
 
bool IsTheLowestBitSet () const
 
bool IsOnlyTheHighestBitSet () const
 
bool IsOnlyTheLowestBitSet () const
 
bool IsZero () const
 
bool AreFirstBitsZero (uint bits) const
 
template<uint argument_size>
uint FromUInt (const UInt< argument_size > &p)
 
template<uint argument_size>
uint FromInt (const UInt< argument_size > &p)
 
uint FromUInt (uint value)
 
uint FromInt (uint value)
 
uint FromInt (sint value)
 
template<uint argument_size>
UInt< value_size > & operator= (const UInt< argument_size > &p)
 
UInt< value_size > & operator= (const UInt< value_size > &p)
 
UInt< value_size > & operator= (uint i)
 
 UInt (uint i)
 
UInt< value_size > & operator= (sint i)
 
 UInt (sint i)
 
uint FromUInt (ulint n)
 
uint FromInt (ulint n)
 
uint FromInt (slint n)
 
UInt< value_size > & operator= (ulint n)
 
 UInt (ulint n)
 
UInt< value_size > & operator= (slint n)
 
 UInt (slint n)
 
 UInt (const char *s)
 
 UInt (const std::string &s)
 
 UInt (const wchar_t *s)
 
 UInt (const std::wstring &s)
 
 UInt ()
 
 UInt (const UInt< value_size > &u)
 
template<uint argument_size>
 UInt (const UInt< argument_size > &u)
 
 ~UInt ()
 
uint ToUInt () const
 
uint ToUInt (uint &result) const
 
uint ToInt (uint &result) const
 
uint ToInt (sint &result) const
 
uint ToUInt (ulint &result) const
 
uint ToInt (ulint &result) const
 
uint ToInt (slint &result) const
 
template<class string_type >
void ToStringBase (string_type &result, uint b=10, bool negative=false) const
 
void ToString (std::string &result, uint b=10) const
 
std::string ToString (uint b=10) const
 
void ToString (std::wstring &result, uint b=10) const
 
std::wstring ToWString (uint b=10) const
 
uint FromString (const char *s, uint b=10, const char **after_source=0, bool *value_read=0)
 
uint FromString (const std::string &s, uint b=10)
 
UInt< value_size > & operator= (const char *s)
 
UInt< value_size > & operator= (const std::string &s)
 
uint FromString (const wchar_t *s, uint b=10, const wchar_t **after_source=0, bool *value_read=0)
 
uint FromString (const std::wstring &s, uint b=10)
 
UInt< value_size > & operator= (const wchar_t *s)
 
UInt< value_size > & operator= (const std::wstring &s)
 
bool CmpSmaller (const UInt< value_size > &l, sint index=-1) const
 
bool CmpBigger (const UInt< value_size > &l, sint index=-1) const
 
bool CmpEqual (const UInt< value_size > &l, sint index=-1) const
 
bool CmpSmallerEqual (const UInt< value_size > &l, sint index=-1) const
 
bool CmpBiggerEqual (const UInt< value_size > &l, sint index=-1) const
 
bool operator< (const UInt< value_size > &l) const
 
bool operator> (const UInt< value_size > &l) const
 
bool operator== (const UInt< value_size > &l) const
 
bool operator!= (const UInt< value_size > &l) const
 
bool operator<= (const UInt< value_size > &l) const
 
bool operator>= (const UInt< value_size > &l) const
 
UInt< value_size > operator- (const UInt< value_size > &p2) const
 
UInt< value_size > & operator-= (const UInt< value_size > &p2)
 
UInt< value_size > operator+ (const UInt< value_size > &p2) const
 
UInt< value_size > & operator+= (const UInt< value_size > &p2)
 
UInt< value_size > operator* (const UInt< value_size > &p2) const
 
UInt< value_size > & operator*= (const UInt< value_size > &p2)
 
UInt< value_size > operator/ (const UInt< value_size > &p2) const
 
UInt< value_size > & operator/= (const UInt< value_size > &p2)
 
UInt< value_size > operator% (const UInt< value_size > &p2) const
 
UInt< value_size > & operator%= (const UInt< value_size > &p2)
 
UInt< value_size > & operator++ ()
 
UInt< value_size > operator++ (int)
 
UInt< value_size > & operator-- ()
 
UInt< value_size > operator-- (int)
 
UInt< value_size > operator~ () const
 
UInt< value_size > operator& (const UInt< value_size > &p2) const
 
UInt< value_size > & operator&= (const UInt< value_size > &p2)
 
UInt< value_size > operator| (const UInt< value_size > &p2) const
 
UInt< value_size > & operator|= (const UInt< value_size > &p2)
 
UInt< value_size > operator^ (const UInt< value_size > &p2) const
 
UInt< value_size > & operator^= (const UInt< value_size > &p2)
 
UInt< value_size > operator>> (int move) const
 
UInt< value_size > & operator>>= (int move)
 
UInt< value_size > operator<< (int move) const
 
UInt< value_size > & operator<<= (int move)
 
uint Add (const UInt< value_size > &ss2, uint c=0)
 
uint AddInt (uint value, uint index=0)
 
uint AddTwoInts (uint x2, uint x1, uint index)
 
uint Sub (const UInt< value_size > &ss2, uint c=0)
 
uint SubInt (uint value, uint index=0)
 

Friends

std::ostream & operator<< (std::ostream &s, const Int< value_size > &l)
 
std::wostream & operator<< (std::wostream &s, const Int< value_size > &l)
 
std::istream & operator>> (std::istream &s, Int< value_size > &l)
 
std::wistream & operator>> (std::wistream &s, Int< value_size > &l)
 

Additional Inherited Members

- Static Public Member Functions inherited from ttmath::UInt< value_size >
template<class char_type , class ostream_type >
static void PrintVectorLog (const char_type *msg, ostream_type &output, const uint *vector, uint vector_len)
 
template<class char_type , class ostream_type >
static void PrintVectorLog (const char_type *msg, uint carry, ostream_type &output, const uint *vector, uint vector_len)
 
static uint AddTwoWords (uint a, uint b, uint carry, uint *result)
 
static uint SubTwoWords (uint a, uint b, uint carry, uint *result)
 
static const char * LibTypeStr ()
 
static LibTypeCode LibType ()
 
static uint AddVector (const uint *ss1, const uint *ss2, uint ss1_size, uint ss2_size, uint *result)
 
static uint SubVector (const uint *ss1, const uint *ss2, uint ss1_size, uint ss2_size, uint *result)
 
static sint FindLeadingBitInWord (uint x)
 
static sint FindLowestBitInWord (uint x)
 
static uint SetBitInWord (uint &value, uint bit)
 
static void MulTwoWords (uint a, uint b, uint *result_high, uint *result_low)
 
static void DivTwoWords (uint a, uint b, uint c, uint *r, uint *rest)
 
- Public Attributes inherited from ttmath::UInt< value_size >
uint table [value_size]
 
- Protected Member Functions inherited from ttmath::UInt< value_size >
double ToStringLog2 (uint x) const
 

Detailed Description

template<uint value_size>
class ttmath::Int< value_size >

Int implements a big integer value with a sign.

value_size - how many bytes specify our value on 32bit platforms: value_size=1 -> 4 bytes -> 32 bits on 64bit platforms: value_size=1 -> 8 bytes -> 64 bits value_size = 1,2,3,4,5,6....

Constructor & Destructor Documentation

template<uint value_size>
ttmath::Int< value_size >::Int ( sint  i)
inline

a constructor for converting the uint to this class

template<uint value_size>
ttmath::Int< value_size >::Int ( const Int< value_size > &  u)
inline

a copy constructor

template<uint value_size>
template<uint argument_size>
ttmath::Int< value_size >::Int ( const Int< argument_size > &  u)
inline

a constructor for copying from another types

template<uint value_size>
ttmath::Int< value_size >::Int ( uint  i)
inline

a constructor for converting the uint to this class

template<uint value_size>
template<uint argument_size>
ttmath::Int< value_size >::Int ( const UInt< argument_size > &  u)
inline

a constructor for copying from another types

template<uint value_size>
ttmath::Int< value_size >::Int ( ulint  n)
inline

a constructor for converting unsigned 64 bit int to this class this constructor is created only on a 32bit platform***

template<uint value_size>
ttmath::Int< value_size >::Int ( slint  n)
inline

a constructor for converting signed 64 bit int to this class this constructor is created only on a 32bit platform***

template<uint value_size>
ttmath::Int< value_size >::Int ( const char *  s)
inline

a constructor for converting string to this class (with the base=10)

template<uint value_size>
ttmath::Int< value_size >::Int ( const std::string &  s)
inline

a constructor for converting a string to this class (with the base=10)

template<uint value_size>
ttmath::Int< value_size >::Int ( const wchar_t *  s)
inline

a constructor for converting string to this class (with the base=10)

template<uint value_size>
ttmath::Int< value_size >::Int ( const std::wstring &  s)
inline

a constructor for converting a string to this class (with the base=10)

template<uint value_size>
ttmath::Int< value_size >::Int ( )
inline

a default constructor

we don't clear table etc.

template<uint value_size>
ttmath::Int< value_size >::~Int ( )
inline

the destructor

Member Function Documentation

template<uint value_size>
uint ttmath::Int< value_size >::Abs ( )
inline

it sets an absolute value

it can return carry (1) (look on ChangeSign() for details)

template<uint value_size>
uint ttmath::Int< value_size >::Add ( const Int< value_size > &  ss2)
inline

this method adds two value with a sign and returns a carry

we're using methods from the base class because values are stored with U2 we must only make the carry correction

this = p1(=this) + p2

when p1>=0 i p2>=0 carry is set when the highest bit of value is set when p1<0 i p2<0 carry is set when the highest bit of value is clear when p1>=0 i p2<0 carry will never be set when p1<0 i p2>=0 carry will never be set

template<uint value_size>
uint ttmath::Int< value_size >::AddInt ( uint  value,
uint  index = 0 
)
inline

this method adds one unsigned word (at a specific position) and returns a carry (if it was)

look at a description in UInt<>::AddInt(...)

template<uint value_size>
uint ttmath::Int< value_size >::AddOne ( )
inline

this method adds one to the value and returns carry

template<uint value_size>
uint ttmath::Int< value_size >::AddTwoInts ( uint  x2,
uint  x1,
uint  index 
)
inline

this method adds two unsigned words to the existing value and these words begin on the 'index' position

index should be equal or smaller than value_size-2 (index <= value_size-2) x1 - lower word, x2 - higher word

look at a description in UInt<>::AddTwoInts(...)

template<uint value_size>
uint ttmath::Int< value_size >::ChangeSign ( )
inline

we change the sign of the value

if it isn't possible to change the sign this method returns 1 else return 0 and changing the sign

template<uint value_size>
uint ttmath::Int< value_size >::Div ( Int< value_size >  ss2,
Int< value_size > *  remainder = 0 
)
inline

division this = this / ss2 returned values: 0 - ok 1 - division by zero

for example: (result means 'this') 20 / 3 –> result: 6 remainder: 2 -20 / 3 –> result: -6 remainder: -2 20 / -3 –> result: -6 remainder: 2 -20 / -3 –> result: 6 remainder: -2

in other words: this(old) = ss2 * this(new)(result) + remainder

template<uint value_size>
uint ttmath::Int< value_size >::Div ( const Int< value_size > &  ss2,
Int< value_size > &  remainder 
)
inline
template<uint value_size>
uint ttmath::Int< value_size >::DivInt ( sint  ss2,
sint remainder = 0 
)
inline

division this = this / ss2 (ss2 is int) returned values: 0 - ok 1 - division by zero

for example: (result means 'this') 20 / 3 –> result: 6 remainder: 2 -20 / 3 –> result: -6 remainder: -2 20 / -3 –> result: -6 remainder: 2 -20 / -3 –> result: 6 remainder: -2

in other words: this(old) = ss2 * this(new)(result) + remainder

template<uint value_size>
uint ttmath::Int< value_size >::DivInt ( sint  ss2,
sint remainder 
)
inline
template<uint value_size>
template<uint argument_size>
uint ttmath::Int< value_size >::FromInt ( const Int< argument_size > &  p)
inline

this method converts an Int<another_size> type into this class

this operation has mainly sense if the value from p can be held in this type

it returns a carry if the value 'p' is too big

template<uint value_size>
uint ttmath::Int< value_size >::FromInt ( sint  value)
inline

this method converts the sint type into this class

template<uint value_size>
template<uint argument_size>
uint ttmath::Int< value_size >::FromInt ( const UInt< argument_size > &  p)
inline

this method converts UInt<another_size> into this class

template<uint value_size>
uint ttmath::Int< value_size >::FromInt ( uint  value)
inline

this method converts the uint type into this class

template<uint value_size>
uint ttmath::Int< value_size >::FromInt ( ulint  n)
inline

this method converts unsigned 64 bit int type to this class this method is created only on a 32bit platform***

template<uint value_size>
uint ttmath::Int< value_size >::FromInt ( slint  n)
inline

this method converts signed 64 bit int type to this class this method is created only on a 32bit platform***

template<uint value_size>
uint ttmath::Int< value_size >::FromString ( const char *  s,
uint  b = 10,
const char **  after_source = 0,
bool *  value_read = 0 
)
inline

this method converts a string into its value it returns carry=1 if the value will be too big or an incorrect base 'b' is given

string is ended with a non-digit value, for example: "-12" will be translated to -12 as well as: "- 12foo" will be translated to -12 too

existing first white characters will be ommited (between '-' and a first digit can be white characters too)

after_source (if exists) is pointing at the end of the parsed string

value_read (if exists) tells whether something has actually been read (at least one digit)

template<uint value_size>
uint ttmath::Int< value_size >::FromString ( const wchar_t *  s,
uint  b = 10,
const wchar_t **  after_source = 0,
bool *  value_read = 0 
)
inline

this method converts a string into its value

template<uint value_size>
uint ttmath::Int< value_size >::FromString ( const std::string &  s,
uint  b = 10 
)
inline

this method converts a string into its value it returns carry=1 if the value will be too big or an incorrect base 'b' is given

template<uint value_size>
uint ttmath::Int< value_size >::FromString ( const std::wstring &  s,
uint  b = 10 
)
inline

this method converts a string into its value it returns carry=1 if the value will be too big or an incorrect base 'b' is given

template<uint value_size>
template<uint argument_size>
uint ttmath::Int< value_size >::FromUInt ( const UInt< argument_size > &  p)
inline

this method converts UInt<another_size> into this class

template<uint value_size>
uint ttmath::Int< value_size >::FromUInt ( uint  value)
inline

this method converts the uint type into this class

template<uint value_size>
uint ttmath::Int< value_size >::FromUInt ( ulint  n)
inline

this method converts unsigned 64 bit int type to this class this method is created only on a 32bit platform***

template<uint value_size>
bool ttmath::Int< value_size >::IsSign ( ) const
inline

this method returns true if there's the sign

(the highest bit will be converted to the bool)

template<uint value_size>
uint ttmath::Int< value_size >::Mul ( Int< value_size >  ss2)
inline

multiplication this = this * ss2

it returns carry if the result is too big (we're using the method from the base class but we have to make one correction in account of signs)

template<uint value_size>
uint ttmath::Int< value_size >::MulInt ( sint  ss2)
inline

multiplication: this = this * ss2

it can return a carry

template<uint value_size>
bool ttmath::Int< value_size >::operator!= ( const Int< value_size > &  l) const
inline
template<uint value_size>
Int<value_size> ttmath::Int< value_size >::operator% ( const Int< value_size > &  p2) const
inline
template<uint value_size>
Int<value_size>& ttmath::Int< value_size >::operator%= ( const Int< value_size > &  p2)
inline
template<uint value_size>
Int<value_size> ttmath::Int< value_size >::operator* ( const Int< value_size > &  p2) const
inline
template<uint value_size>
Int<value_size>& ttmath::Int< value_size >::operator*= ( const Int< value_size > &  p2)
inline
template<uint value_size>
Int<value_size> ttmath::Int< value_size >::operator+ ( const Int< value_size > &  p2) const
inline
template<uint value_size>
UInt<value_size>& ttmath::Int< value_size >::operator++ ( )
inline

Prefix operator e.g. ++variable

template<uint value_size>
UInt<value_size> ttmath::Int< value_size >::operator++ ( int  )
inline

Postfix operator e.g. variable++

template<uint value_size>
Int<value_size>& ttmath::Int< value_size >::operator+= ( const Int< value_size > &  p2)
inline
template<uint value_size>
Int<value_size> ttmath::Int< value_size >::operator- ( ) const
inline

standard mathematical operators

an operator for changing the sign

it's not changing 'this' but the changed value will be returned

template<uint value_size>
Int<value_size> ttmath::Int< value_size >::operator- ( const Int< value_size > &  p2) const
inline
template<uint value_size>
UInt<value_size>& ttmath::Int< value_size >::operator-- ( )
inline
template<uint value_size>
UInt<value_size> ttmath::Int< value_size >::operator-- ( int  )
inline
template<uint value_size>
Int<value_size>& ttmath::Int< value_size >::operator-= ( const Int< value_size > &  p2)
inline
template<uint value_size>
Int<value_size> ttmath::Int< value_size >::operator/ ( const Int< value_size > &  p2) const
inline
template<uint value_size>
Int<value_size>& ttmath::Int< value_size >::operator/= ( const Int< value_size > &  p2)
inline
template<uint value_size>
bool ttmath::Int< value_size >::operator< ( const Int< value_size > &  l) const
inline
template<uint value_size>
bool ttmath::Int< value_size >::operator<= ( const Int< value_size > &  l) const
inline
template<uint value_size>
Int<value_size>& ttmath::Int< value_size >::operator= ( const Int< value_size > &  p)
inline

the default assignment operator

template<uint value_size>
template<uint argument_size>
Int<value_size>& ttmath::Int< value_size >::operator= ( const Int< argument_size > &  p)
inline

this operator converts an Int<another_size> type to this class

it doesn't return a carry

template<uint value_size>
Int<value_size>& ttmath::Int< value_size >::operator= ( sint  i)
inline

this method converts the sint type to this class

template<uint value_size>
template<uint argument_size>
Int<value_size>& ttmath::Int< value_size >::operator= ( const UInt< argument_size > &  p)
inline

this operator converts an UInt<another_size> type to this class

it doesn't return a carry

template<uint value_size>
Int<value_size>& ttmath::Int< value_size >::operator= ( uint  i)
inline

this method converts the Uint type to this class

template<uint value_size>
Int<value_size>& ttmath::Int< value_size >::operator= ( ulint  n)
inline

this operator converts unsigned 64 bit int type to this class this operator is created only on a 32bit platform***

template<uint value_size>
Int<value_size>& ttmath::Int< value_size >::operator= ( slint  n)
inline

this operator converts signed 64 bit int type to this class this operator is created only on a 32bit platform***

template<uint value_size>
Int<value_size>& ttmath::Int< value_size >::operator= ( const char *  s)
inline

this operator converts a string into its value (with base = 10)

template<uint value_size>
Int<value_size>& ttmath::Int< value_size >::operator= ( const wchar_t *  s)
inline

this operator converts a string into its value (with base = 10)

template<uint value_size>
Int<value_size>& ttmath::Int< value_size >::operator= ( const std::wstring &  s)
inline

this operator converts a string into its value (with base = 10)

template<uint value_size>
Int<value_size>& ttmath::Int< value_size >::operator= ( const std::string &  s)
inline

this operator converts a string into its value (with base = 10)

template<uint value_size>
bool ttmath::Int< value_size >::operator== ( const Int< value_size > &  l) const
inline

methods for comparing

template<uint value_size>
bool ttmath::Int< value_size >::operator> ( const Int< value_size > &  l) const
inline
template<uint value_size>
bool ttmath::Int< value_size >::operator>= ( const Int< value_size > &  l) const
inline
template<uint value_size>
uint ttmath::Int< value_size >::Pow ( Int< value_size >  pow)
inline

power this = this ^ pow

return values: 0 - ok 1 - carry 2 - incorrect arguments 0^0 or 0^(-something)

template<uint value_size>
void ttmath::Int< value_size >::SetMax ( )
inline

this method sets the max value which this class can hold (all bits will be one besides the last one)

template<uint value_size>
void ttmath::Int< value_size >::SetMin ( )
inline

this method sets the min value which this class can hold (all bits will be zero besides the last one which is one)

template<uint value_size>
void ttmath::Int< value_size >::SetSign ( )
inline

this method sets the sign

e.g. 1 -> -1 -2 -> -2

from a positive value we make a negative value, if the value is negative we do nothing

template<uint value_size>
void ttmath::Int< value_size >::SetSignOne ( )
inline

this method sets -1 as the value (-1 is equal the max value in an unsigned type)

template<uint value_size>
uint ttmath::Int< value_size >::Sub ( const Int< value_size > &  ss2)
inline

this method subtracts two values with a sign

we don't use the previous Add because the method ChangeSign can sometimes return carry

this = p1(=this) - p2

when p1>=0 i p2>=0 carry will never be set when p1<0 i p2<0 carry will never be set when p1>=0 i p2<0 carry is set when the highest bit of value is set when p1<0 i p2>=0 carry is set when the highest bit of value is clear

template<uint value_size>
uint ttmath::Int< value_size >::SubInt ( uint  value,
uint  index = 0 
)
inline

this method subtracts one unsigned word (at a specific position) and returns a carry (if it was)

template<uint value_size>
uint ttmath::Int< value_size >::SubOne ( )
inline

this method subtracts one from the value and returns carry

template<uint value_size>
sint ttmath::Int< value_size >::ToInt ( ) const
inline

this method returns the lowest value from table with a sign

we must be sure when we using this method whether the value will hold in an sint type or not (the rest value from table must be zero or -1)

template<uint value_size>
uint ttmath::Int< value_size >::ToInt ( uint result) const
inline

this method converts the value to uint type can return a carry if the value is too long to store it in uint type

template<uint value_size>
uint ttmath::Int< value_size >::ToInt ( sint result) const
inline

this method converts the value to sint type can return a carry if the value is too long to store it in sint type

template<uint value_size>
uint ttmath::Int< value_size >::ToInt ( ulint result) const
inline

this method converts the value to ulint type (64 bit unsigned integer) can return a carry if the value is too long to store it in ulint type this method is created only on a 32 bit platform ***

template<uint value_size>
uint ttmath::Int< value_size >::ToInt ( slint result) const
inline

this method converts the value to slint type (64 bit signed integer) can return a carry if the value is too long to store it in slint type this method is created only on a 32 bit platform ***

template<uint value_size>
void ttmath::Int< value_size >::ToString ( std::string &  result,
uint  b = 10 
) const
inline

this method converts the value to a string with a base equal 'b'

template<uint value_size>
std::string ttmath::Int< value_size >::ToString ( uint  b = 10) const
inline

this method converts the value to a string with a base equal 'b'

template<uint value_size>
void ttmath::Int< value_size >::ToString ( std::wstring &  result,
uint  b = 10 
) const
inline

this method converts the value to a string with a base equal 'b'

template<uint value_size>
uint ttmath::Int< value_size >::ToUInt ( uint result) const
inline

this method converts the value to uint type can return a carry if the value is too long to store it in uint type

template<uint value_size>
uint ttmath::Int< value_size >::ToUInt ( ulint result) const
inline

this method converts the value to ulint type (64 bit unsigned integer) can return a carry if the value is too long to store it in ulint type this method is created only on a 32 bit platform ***

template<uint value_size>
std::wstring ttmath::Int< value_size >::ToWString ( uint  b = 10) const
inline

this method converts the value to a string with a base equal 'b'

Friends And Related Function Documentation

template<uint value_size>
std::ostream& operator<< ( std::ostream &  s,
const Int< value_size > &  l 
)
friend

output to standard streams

template<uint value_size>
std::wostream& operator<< ( std::wostream &  s,
const Int< value_size > &  l 
)
friend

output to standard streams

template<uint value_size>
std::istream& operator>> ( std::istream &  s,
Int< value_size > &  l 
)
friend

input from standard streams

template<uint value_size>
std::wistream& operator>> ( std::wistream &  s,
Int< value_size > &  l 
)
friend

input from standard streams


The documentation for this class was generated from the following file: