"L. Spiro Engine"
|
A large-integer template class. More...
#include <lsstdlargeinteger.h>
Public Member Functions | |
LSE_CALL | CLargeInteger () |
LSE_CALL | CLargeInteger (const CLargeInteger< _uMaxDigits > &_liOther) |
LSE_CALL | CLargeInteger (LSINT64 _i64Value) |
LSE_CALL | CLargeInteger (LSUINT64 _ui64Value) |
LSE_CALL | CLargeInteger (LSINT32 _i32Value) |
LSE_CALL | CLargeInteger (LSUINT32 _ui32Value) |
LSE_CALL | CLargeInteger (const LSUINT32 *_pui8Array, LSUINT32 _ui32Length) |
CLargeInteger< _uMaxDigits > LSE_CALL | operator+ (const CLargeInteger< _uMaxDigits > &_liOp) const |
CLargeInteger< _uMaxDigits > LSE_CALL | operator- (const CLargeInteger< _uMaxDigits > &_liOp) const |
CLargeInteger< _uMaxDigits > LSE_CALL | operator* (const CLargeInteger< _uMaxDigits > &_liOp) const |
CLargeInteger< _uMaxDigits > LSE_CALL | operator*= (const CLargeInteger< _uMaxDigits > &_liOp) |
CLargeInteger< _uMaxDigits > LSE_CALL | operator/ (const CLargeInteger< _uMaxDigits > &_liOp) const |
CLargeInteger< _uMaxDigits > LSE_CALL | operator/= (const CLargeInteger< _uMaxDigits > &_liOp) |
CLargeInteger< _uMaxDigits > LSE_CALL | operator% (const CLargeInteger< _uMaxDigits > &_liOp) const |
CLargeInteger< _uMaxDigits > LSE_CALL | operator- () const |
CLargeInteger< _uMaxDigits > LSE_CALL | operator= (const CLargeInteger< _uMaxDigits > &_liOp) |
CLargeInteger< _uMaxDigits > LSE_CALL | operator<< (LSUINT32 _ui32Shift) const |
CLargeInteger< _uMaxDigits > &LSE_CALL | operator<<= (LSUINT32 _ui32Shift) |
CLargeInteger< _uMaxDigits > LSE_CALL | operator>> (LSUINT32 _ui32Shift) const |
CLargeInteger< _uMaxDigits > &LSE_CALL | operator>>= (LSUINT32 _ui32Shift) |
CLargeInteger< _uMaxDigits > LSE_CALL | operator& (const CLargeInteger< _uMaxDigits > &_liOp) const |
CLargeInteger< _uMaxDigits > &LSE_CALL | operator&= (const CLargeInteger< _uMaxDigits > &_liOp) |
CLargeInteger< _uMaxDigits > LSE_CALL | operator| (const CLargeInteger< _uMaxDigits > &_liOp) const |
CLargeInteger< _uMaxDigits > &LSE_CALL | operator|= (const CLargeInteger< _uMaxDigits > &_liOp) |
CLargeInteger< _uMaxDigits > LSE_CALL | operator^ (const CLargeInteger< _uMaxDigits > &_liOp) const |
CLargeInteger< _uMaxDigits > &LSE_CALL | operator^= (const CLargeInteger< _uMaxDigits > &_liOp) |
bool LSE_CALL | operator> (const CLargeInteger< _uMaxDigits > &_liOp) const |
bool LSE_CALL | operator< (const CLargeInteger< _uMaxDigits > &_liOp) const |
bool LSE_CALL | operator== (const CLargeInteger< _uMaxDigits > &_liOp) const |
bool LSE_CALL | operator!= (const CLargeInteger< _uMaxDigits > &_liOp) const |
bool LSE_CALL | operator>= (const CLargeInteger< _uMaxDigits > &_liOp) const |
bool LSE_CALL | operator<= (const CLargeInteger< _uMaxDigits > &_liOp) const |
LSUINT64 LSE_CALL | GetAs64bitUInt () const |
LSUINT32 LSE_CALL | GetAs32bitUInt () const |
LSUINT32 *LSE_CALL | GetBytes () |
LSUINT32 LSE_CALL | GetLength () const |
LSVOID LSE_CALL | SetLength (LSUINT32 _ui32Length) |
template<typename _tType > | |
LSUINT32 LSE_CALL | ToString (_tType *_ptString, LSUINT32 _ui32MaxLen, LSUINT32 _ui32Radix) |
Static Public Member Functions | |
static LSVOID LSE_CALL | Add (const CLargeInteger< _uMaxDigits > &_liLeft, const CLargeInteger< _uMaxDigits > &_liRight, CLargeInteger< _uMaxDigits > &_liResult) |
static LSVOID LSE_CALL | Subtract (const CLargeInteger< _uMaxDigits > &_liLeft, const CLargeInteger< _uMaxDigits > &_liRight, CLargeInteger< _uMaxDigits > &_liResult) |
static LSVOID LSE_CALL | Multiply (const CLargeInteger< _uMaxDigits > &_liLeft, const CLargeInteger< _uMaxDigits > &_liRight, CLargeInteger< _uMaxDigits > &_liResult) |
static LSVOID LSE_CALL | Divide (const CLargeInteger< _uMaxDigits > &_liLeft, const CLargeInteger< _uMaxDigits > &_liRight, CLargeInteger< _uMaxDigits > &_liResult) |
static LSVOID LSE_CALL | Modulus (const CLargeInteger< _uMaxDigits > &_liLeft, const CLargeInteger< _uMaxDigits > &_liRight, CLargeInteger< _uMaxDigits > &_liResult) |
static LSVOID LSE_CALL | Negate (const CLargeInteger< _uMaxDigits > &_liValue, CLargeInteger< _uMaxDigits > &_liResult) |
static LSUINT32 LSE_CALL | ShiftLeft (LSUINT32 *_pui32Data, LSUINT32 _ui32Len, LSUINT32 _ui32Amount) |
static LSUINT32 LSE_CALL | ShiftRight (LSUINT32 *_pui32Data, LSUINT32 _ui32Len, LSUINT32 _ui32Amount) |
Protected Attributes | |
LSUINT32 | m_ui32Digits [_uMaxDigits] |
LSUINT32 | m_ui32UsedDigits |
A large-integer template class.
Class CLargeInteger Description: A large-integer template class. Represents a number containing at most _uMaxDigits digits in radix 10. Provides standard operators synthesized in software mode. This class is not intended for use in any high-performance situation. Use this class when precision is more important than speed.
Multiple instances of this class can cause a heavy hit to the stack unless allocated to the heap.
LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::CLargeInteger | ( | ) | [inline] |
Create a large integer. The integer is initialized to 0.
LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::CLargeInteger | ( | const CLargeInteger< _uMaxDigits > & | _liOther | ) | [inline] |
Create a large integer as a copy of another.
_liOther | The source large integer. |
LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::CLargeInteger | ( | LSINT64 | _i64Value | ) | [inline] |
Create a large integer from a signed 64-bit value.
_i64Value | The value to be converted to a large integer. |
LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::CLargeInteger | ( | LSUINT64 | _ui64Value | ) | [inline] |
Create a large integer from an unsigned 64-bit value.
_ui64Value | The value to be converted to a large integer. |
LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::CLargeInteger | ( | LSINT32 | _i32Value | ) | [inline] |
Create a large integer from a signed 32-bit value.
_i32Value | The value to be converted to a large integer. |
LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::CLargeInteger | ( | LSUINT32 | _ui32Value | ) | [inline] |
Create a large integer from an unsigned 32-bit value.
_ui32Value | The value to be converted to a large integer. |
LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::CLargeInteger | ( | const LSUINT32 * | _pui8Array, |
LSUINT32 | _ui32Length | ||
) | [inline] |
Create a large integer from an array of bytes.
_pui8Array | The array of bytes. |
_ui32Length | The number of bytes in the array. |
static LSVOID LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::Add | ( | const CLargeInteger< _uMaxDigits > & | _liLeft, |
const CLargeInteger< _uMaxDigits > & | _liRight, | ||
CLargeInteger< _uMaxDigits > & | _liResult | ||
) | [inline, static] |
Add two large integers together and store the result in a third. An exception is thrown on overflow.
_liLeft | Left operand. |
_liRight | Right operand. |
_liResult | Result. |
static LSVOID LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::Divide | ( | const CLargeInteger< _uMaxDigits > & | _liLeft, |
const CLargeInteger< _uMaxDigits > & | _liRight, | ||
CLargeInteger< _uMaxDigits > & | _liResult | ||
) | [inline, static] |
Divide two large integers and store the result in a third. An exception is thrown if the right operand is 0.
_liLeft | Left operand. |
_liRight | Right operand. |
_liResult | Result. |
LSUINT32 LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::GetAs32bitUInt | ( | ) | const [inline] |
Get the value of this large integer as an unsigned 32-bit integer. Throws an exception if the value of this integer is too large to be held by a 32-bit integer.
LSUINT64 LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::GetAs64bitUInt | ( | ) | const [inline] |
Get the value of this large integer as an unsigned 64-bit integer. Throws an exception if the value of this integer is too large to be held by a 64-bit integer.
LSUINT32* LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::GetBytes | ( | ) | [inline] |
Get our bytes.
LSUINT32 LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::GetLength | ( | ) | const [inline] |
Get the length of our bytes.
static LSVOID LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::Modulus | ( | const CLargeInteger< _uMaxDigits > & | _liLeft, |
const CLargeInteger< _uMaxDigits > & | _liRight, | ||
CLargeInteger< _uMaxDigits > & | _liResult | ||
) | [inline, static] |
Obtain the modulus of two large integers and store the result in a third. An exception is thrown if the right operand is 0.
_liLeft | Left operand. |
_liRight | Right operand. |
_liResult | Result. |
static LSVOID LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::Multiply | ( | const CLargeInteger< _uMaxDigits > & | _liLeft, |
const CLargeInteger< _uMaxDigits > & | _liRight, | ||
CLargeInteger< _uMaxDigits > & | _liResult | ||
) | [inline, static] |
Multiply two large integers and store the result in a third. An exception is thrown on overflow.
_liLeft | Left operand. |
_liRight | Right operand. |
_liResult | Result. |
static LSVOID LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::Negate | ( | const CLargeInteger< _uMaxDigits > & | _liValue, |
CLargeInteger< _uMaxDigits > & | _liResult | ||
) | [inline, static] |
Negate a large integer.
_liValue | The value to negate. |
_liResult | Result. |
bool LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator!= | ( | const CLargeInteger< _uMaxDigits > & | _liOp | ) | const [inline] |
Inequality comparison.
_liOp | The right operand. |
CLargeInteger<_uMaxDigits> LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator% | ( | const CLargeInteger< _uMaxDigits > & | _liOp | ) | const [inline] |
Modulus two large integers to create a third large integer holding the result. An exception is thrown if the right operand is 0.
_liOp | The right operand. |
CLargeInteger<_uMaxDigits> LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator& | ( | const CLargeInteger< _uMaxDigits > & | _liOp | ) | const [inline] |
Bitwise AND operator. The result is returned.
_liOp | The right operand. |
CLargeInteger<_uMaxDigits>& LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator&= | ( | const CLargeInteger< _uMaxDigits > & | _liOp | ) | [inline] |
Bitwise AND operator with assignent. The result is returned.
_liOp | The right operand. |
CLargeInteger<_uMaxDigits> LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator* | ( | const CLargeInteger< _uMaxDigits > & | _liOp | ) | const [inline] |
Multiply two large integers to create a third large integer holding the result. An exception is thrown on overflow.
_liOp | The right operand. |
CLargeInteger<_uMaxDigits> LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator*= | ( | const CLargeInteger< _uMaxDigits > & | _liOp | ) | [inline] |
Multiply this large integer by other, assiging the result to this large integer. An exception is thrown on overflow.
_liOp | The right operand. |
CLargeInteger<_uMaxDigits> LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator+ | ( | const CLargeInteger< _uMaxDigits > & | _liOp | ) | const [inline] |
Add two large integers to create a third large integer holding the result. An exception is thrown on overflow.
_liOp | The right operand. |
CLargeInteger<_uMaxDigits> LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator- | ( | ) | const [inline] |
Perform unary negation on this number. The negated value is returned.
CLargeInteger<_uMaxDigits> LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator- | ( | const CLargeInteger< _uMaxDigits > & | _liOp | ) | const [inline] |
Subtract two large integers to create a third large integer holding the result. An exception is thrown on overflow.
_liOp | The right operand. |
CLargeInteger<_uMaxDigits> LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator/ | ( | const CLargeInteger< _uMaxDigits > & | _liOp | ) | const [inline] |
Divide two large integers to create a third large integer holding the result. An exception is thrown if the right operand is 0.
_liOp | The right operand. |
CLargeInteger<_uMaxDigits> LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator/= | ( | const CLargeInteger< _uMaxDigits > & | _liOp | ) | [inline] |
Divide this large integer by other, assiging the result to this large integer. An exception is thrown if the right operand is 0.
_liOp | The right operand. |
bool LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator< | ( | const CLargeInteger< _uMaxDigits > & | _liOp | ) | const [inline] |
Less-than comparison.
_liOp | The right operand. |
CLargeInteger<_uMaxDigits> LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator<< | ( | LSUINT32 | _ui32Shift | ) | const [inline] |
Shift bits left by the given amount. The shifted value is returned.
_ui32Shift | The amount by which to shift. |
CLargeInteger<_uMaxDigits>& LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator<<= | ( | LSUINT32 | _ui32Shift | ) | [inline] |
Shift bits left by the given amount, storing the result in this instance.
_ui32Shift | The amount by which to shift. |
bool LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator<= | ( | const CLargeInteger< _uMaxDigits > & | _liOp | ) | const [inline] |
Less-than-or-equal-to comparison.
_liOp | The right operand. |
CLargeInteger<_uMaxDigits> LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator= | ( | const CLargeInteger< _uMaxDigits > & | _liOp | ) | [inline] |
Copy the value of another large integer into this one.
_liOp | The right operand. |
bool LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator== | ( | const CLargeInteger< _uMaxDigits > & | _liOp | ) | const [inline] |
Equality comparison.
_liOp | The right operand. |
bool LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator> | ( | const CLargeInteger< _uMaxDigits > & | _liOp | ) | const [inline] |
Greater-than comparison.
_liOp | The right operand. |
bool LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator>= | ( | const CLargeInteger< _uMaxDigits > & | _liOp | ) | const [inline] |
Greater-than-or-equal-to comparison.
_liOp | The right operand. |
CLargeInteger<_uMaxDigits> LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator>> | ( | LSUINT32 | _ui32Shift | ) | const [inline] |
Shift bits right by the given amount. The shifted value is returned.
_ui32Shift | The amount by which to shift. |
CLargeInteger<_uMaxDigits>& LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator>>= | ( | LSUINT32 | _ui32Shift | ) | [inline] |
Shift bits right by the given amount, storing the result in this instance.
_ui32Shift | The amount by which to shift. |
CLargeInteger<_uMaxDigits> LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator^ | ( | const CLargeInteger< _uMaxDigits > & | _liOp | ) | const [inline] |
Bitwise XOR operator. The result is returned.
_liOp | The right operand. |
CLargeInteger<_uMaxDigits>& LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator^= | ( | const CLargeInteger< _uMaxDigits > & | _liOp | ) | [inline] |
Bitwise XOR operator with assignent. The result is returned.
_liOp | The right operand. |
CLargeInteger<_uMaxDigits> LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator| | ( | const CLargeInteger< _uMaxDigits > & | _liOp | ) | const [inline] |
Bitwise OR operator. The result is returned.
_liOp | The right operand. |
CLargeInteger<_uMaxDigits>& LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator|= | ( | const CLargeInteger< _uMaxDigits > & | _liOp | ) | [inline] |
Bitwise OR operator with assignent. The result is returned.
_liOp | The right operand. |
LSVOID LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::SetLength | ( | LSUINT32 | _ui32Length | ) | [inline] |
Set the length. Never use this.
_ui32Length | The new length of the large integer. |
static LSUINT32 LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::ShiftLeft | ( | LSUINT32 * | _pui32Data, |
LSUINT32 | _ui32Len, | ||
LSUINT32 | _ui32Amount | ||
) | [inline, static] |
Shift bits left (up).
_pui32Data | Acts as both the input array of bytes and the output. |
_ui32Len | Length of the buffer. |
_ui32Amount | Amount by which to shift. |
static LSUINT32 LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::ShiftRight | ( | LSUINT32 * | _pui32Data, |
LSUINT32 | _ui32Len, | ||
LSUINT32 | _ui32Amount | ||
) | [inline, static] |
Shift bits right (down).
_pui32Data | Acts as both the input array of bytes and the output. |
_ui32Len | Length of the buffer. |
_ui32Amount | Amount by which to shift. |
static LSVOID LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::Subtract | ( | const CLargeInteger< _uMaxDigits > & | _liLeft, |
const CLargeInteger< _uMaxDigits > & | _liRight, | ||
CLargeInteger< _uMaxDigits > & | _liResult | ||
) | [inline, static] |
Subtract two large integers together and store the result in a third. An exception is thrown on overflow.
_liLeft | Left operand. |
_liRight | Right operand. |
_liResult | Result. |
LSUINT32 LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::ToString | ( | _tType * | _ptString, |
LSUINT32 | _ui32MaxLen, | ||
LSUINT32 | _ui32Radix | ||
) | [inline] |
Print this number to a string. Returns the number of characters printed or the number of characters needed to print the whole numbr if _ptString is NULL.
_ptString | The output string. |
_ui32MaxLen | The maximum number of characters to print. Ignored if _ptString is NULL. |
_ui32Radix | The radix used for printing. |