"L. Spiro Engine"
Public Member Functions | Static Public Member Functions | Protected Attributes

lsstd::CLargeInteger< _uMaxDigits > Class Template Reference

A large-integer template class. More...

#include <lsstdlargeinteger.h>

List of all members.

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

Detailed Description

template<unsigned _uMaxDigits = 1024UL>
class lsstd::CLargeInteger< _uMaxDigits >

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.


Constructor & Destructor Documentation

template<unsigned _uMaxDigits = 1024UL>
LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::CLargeInteger ( ) [inline]

Create a large integer. The integer is initialized to 0.

template<unsigned _uMaxDigits = 1024UL>
LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::CLargeInteger ( const CLargeInteger< _uMaxDigits > &  _liOther) [inline]

Create a large integer as a copy of another.

Parameters:
_liOtherThe source large integer.
template<unsigned _uMaxDigits = 1024UL>
LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::CLargeInteger ( LSINT64  _i64Value) [inline]

Create a large integer from a signed 64-bit value.

Parameters:
_i64ValueThe value to be converted to a large integer.
template<unsigned _uMaxDigits = 1024UL>
LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::CLargeInteger ( LSUINT64  _ui64Value) [inline]

Create a large integer from an unsigned 64-bit value.

Parameters:
_ui64ValueThe value to be converted to a large integer.
template<unsigned _uMaxDigits = 1024UL>
LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::CLargeInteger ( LSINT32  _i32Value) [inline]

Create a large integer from a signed 32-bit value.

Parameters:
_i32ValueThe value to be converted to a large integer.
template<unsigned _uMaxDigits = 1024UL>
LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::CLargeInteger ( LSUINT32  _ui32Value) [inline]

Create a large integer from an unsigned 32-bit value.

Parameters:
_ui32ValueThe value to be converted to a large integer.
template<unsigned _uMaxDigits = 1024UL>
LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::CLargeInteger ( const LSUINT32 *  _pui8Array,
LSUINT32  _ui32Length 
) [inline]

Create a large integer from an array of bytes.

Parameters:
_pui8ArrayThe array of bytes.
_ui32LengthThe number of bytes in the array.

Member Function Documentation

template<unsigned _uMaxDigits = 1024UL>
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.

Parameters:
_liLeftLeft operand.
_liRightRight operand.
_liResultResult.
template<unsigned _uMaxDigits = 1024UL>
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.

Parameters:
_liLeftLeft operand.
_liRightRight operand.
_liResultResult.
template<unsigned _uMaxDigits = 1024UL>
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.

Returns:
Returns the value of this large integer as a 32-bit integer.
template<unsigned _uMaxDigits = 1024UL>
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.

Returns:
Returns the value of this large integer as a 64-bit integer.
template<unsigned _uMaxDigits = 1024UL>
LSUINT32* LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::GetBytes ( ) [inline]

Get our bytes.

Returns:
Returns the buffer used to store the bytes in this instance. For read and write.
template<unsigned _uMaxDigits = 1024UL>
LSUINT32 LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::GetLength ( ) const [inline]

Get the length of our bytes.

Returns:
Returns the length of this digit.
template<unsigned _uMaxDigits = 1024UL>
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.

Parameters:
_liLeftLeft operand.
_liRightRight operand.
_liResultResult.
template<unsigned _uMaxDigits = 1024UL>
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.

Parameters:
_liLeftLeft operand.
_liRightRight operand.
_liResultResult.
template<unsigned _uMaxDigits = 1024UL>
static LSVOID LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::Negate ( const CLargeInteger< _uMaxDigits > &  _liValue,
CLargeInteger< _uMaxDigits > &  _liResult 
) [inline, static]

Negate a large integer.

Parameters:
_liValueThe value to negate.
_liResultResult.
template<unsigned _uMaxDigits = 1024UL>
bool LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator!= ( const CLargeInteger< _uMaxDigits > &  _liOp) const [inline]

Inequality comparison.

Parameters:
_liOpThe right operand.
Returns:
Returns true if this large integer is not equal to the given large integer.
template<unsigned _uMaxDigits = 1024UL>
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.

Parameters:
_liOpThe right operand.
Returns:
Returns the result as a new large integer.
template<unsigned _uMaxDigits = 1024UL>
CLargeInteger<_uMaxDigits> LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator& ( const CLargeInteger< _uMaxDigits > &  _liOp) const [inline]

Bitwise AND operator. The result is returned.

Parameters:
_liOpThe right operand.
Returns:
Returns the result as a new large integer.
template<unsigned _uMaxDigits = 1024UL>
CLargeInteger<_uMaxDigits>& LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator&= ( const CLargeInteger< _uMaxDigits > &  _liOp) [inline]

Bitwise AND operator with assignent. The result is returned.

Parameters:
_liOpThe right operand.
Returns:
Returns the this instance, which holds the result.
template<unsigned _uMaxDigits = 1024UL>
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.

Parameters:
_liOpThe right operand.
Returns:
Returns the result as a new large integer.
template<unsigned _uMaxDigits = 1024UL>
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.

Parameters:
_liOpThe right operand.
Returns:
Returns this large integer, which will be filled with the result.
template<unsigned _uMaxDigits = 1024UL>
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.

Parameters:
_liOpThe right operand.
Returns:
Returns the result as a new large integer.
template<unsigned _uMaxDigits = 1024UL>
CLargeInteger<_uMaxDigits> LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator- ( ) const [inline]

Perform unary negation on this number. The negated value is returned.

Returns:
Returns the 2's compliment of this number.
template<unsigned _uMaxDigits = 1024UL>
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.

Parameters:
_liOpThe right operand.
Returns:
Returns the result as a new large integer.
template<unsigned _uMaxDigits = 1024UL>
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.

Parameters:
_liOpThe right operand.
Returns:
Returns the result as a new large integer.
template<unsigned _uMaxDigits = 1024UL>
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.

Parameters:
_liOpThe right operand.
Returns:
Returns this large integer, which will be filled with the result.
template<unsigned _uMaxDigits = 1024UL>
bool LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator< ( const CLargeInteger< _uMaxDigits > &  _liOp) const [inline]

Less-than comparison.

Parameters:
_liOpThe right operand.
Returns:
Returns true if this large integer is less than the given large integer.
template<unsigned _uMaxDigits = 1024UL>
CLargeInteger<_uMaxDigits> LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator<< ( LSUINT32  _ui32Shift) const [inline]

Shift bits left by the given amount. The shifted value is returned.

Parameters:
_ui32ShiftThe amount by which to shift.
Returns:
Returns the result as a new large integer.
template<unsigned _uMaxDigits = 1024UL>
CLargeInteger<_uMaxDigits>& LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator<<= ( LSUINT32  _ui32Shift) [inline]

Shift bits left by the given amount, storing the result in this instance.

Parameters:
_ui32ShiftThe amount by which to shift.
Returns:
Returns the this instance, which holds the result.
template<unsigned _uMaxDigits = 1024UL>
bool LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator<= ( const CLargeInteger< _uMaxDigits > &  _liOp) const [inline]

Less-than-or-equal-to comparison.

Parameters:
_liOpThe right operand.
Returns:
Returns true if this large integer is less than or equal to the given large integer.
template<unsigned _uMaxDigits = 1024UL>
CLargeInteger<_uMaxDigits> LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator= ( const CLargeInteger< _uMaxDigits > &  _liOp) [inline]

Copy the value of another large integer into this one.

Parameters:
_liOpThe right operand.
Returns:
Returns the copied number.
template<unsigned _uMaxDigits = 1024UL>
bool LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator== ( const CLargeInteger< _uMaxDigits > &  _liOp) const [inline]

Equality comparison.

Parameters:
_liOpThe right operand.
Returns:
Returns true if this large integer is equal to the given large integer.
template<unsigned _uMaxDigits = 1024UL>
bool LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator> ( const CLargeInteger< _uMaxDigits > &  _liOp) const [inline]

Greater-than comparison.

Parameters:
_liOpThe right operand.
Returns:
Returns true if this large integer is greater than the given large integer.
template<unsigned _uMaxDigits = 1024UL>
bool LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator>= ( const CLargeInteger< _uMaxDigits > &  _liOp) const [inline]

Greater-than-or-equal-to comparison.

Parameters:
_liOpThe right operand.
Returns:
Returns true if this large integer is greater than or equal to the given large integer.
template<unsigned _uMaxDigits = 1024UL>
CLargeInteger<_uMaxDigits> LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator>> ( LSUINT32  _ui32Shift) const [inline]

Shift bits right by the given amount. The shifted value is returned.

Parameters:
_ui32ShiftThe amount by which to shift.
Returns:
Returns the result as a new large integer.
template<unsigned _uMaxDigits = 1024UL>
CLargeInteger<_uMaxDigits>& LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator>>= ( LSUINT32  _ui32Shift) [inline]

Shift bits right by the given amount, storing the result in this instance.

Parameters:
_ui32ShiftThe amount by which to shift.
Returns:
Returns the this instance, which holds the result.
template<unsigned _uMaxDigits = 1024UL>
CLargeInteger<_uMaxDigits> LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator^ ( const CLargeInteger< _uMaxDigits > &  _liOp) const [inline]

Bitwise XOR operator. The result is returned.

Parameters:
_liOpThe right operand.
Returns:
Returns the result as a new large integer.
template<unsigned _uMaxDigits = 1024UL>
CLargeInteger<_uMaxDigits>& LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator^= ( const CLargeInteger< _uMaxDigits > &  _liOp) [inline]

Bitwise XOR operator with assignent. The result is returned.

Parameters:
_liOpThe right operand.
Returns:
Returns the this instance, which holds the result.
template<unsigned _uMaxDigits = 1024UL>
CLargeInteger<_uMaxDigits> LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator| ( const CLargeInteger< _uMaxDigits > &  _liOp) const [inline]

Bitwise OR operator. The result is returned.

Parameters:
_liOpThe right operand.
Returns:
Returns the result as a new large integer.
template<unsigned _uMaxDigits = 1024UL>
CLargeInteger<_uMaxDigits>& LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::operator|= ( const CLargeInteger< _uMaxDigits > &  _liOp) [inline]

Bitwise OR operator with assignent. The result is returned.

Parameters:
_liOpThe right operand.
Returns:
Returns the this instance, which holds the result.
template<unsigned _uMaxDigits = 1024UL>
LSVOID LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::SetLength ( LSUINT32  _ui32Length) [inline]

Set the length. Never use this.

Parameters:
_ui32LengthThe new length of the large integer.
template<unsigned _uMaxDigits = 1024UL>
static LSUINT32 LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::ShiftLeft ( LSUINT32 *  _pui32Data,
LSUINT32  _ui32Len,
LSUINT32  _ui32Amount 
) [inline, static]

Shift bits left (up).

Parameters:
_pui32DataActs as both the input array of bytes and the output.
_ui32LenLength of the buffer.
_ui32AmountAmount by which to shift.
Returns:
Returns the number of used digits.
template<unsigned _uMaxDigits = 1024UL>
static LSUINT32 LSE_CALL lsstd::CLargeInteger< _uMaxDigits >::ShiftRight ( LSUINT32 *  _pui32Data,
LSUINT32  _ui32Len,
LSUINT32  _ui32Amount 
) [inline, static]

Shift bits right (down).

Parameters:
_pui32DataActs as both the input array of bytes and the output.
_ui32LenLength of the buffer.
_ui32AmountAmount by which to shift.
Returns:
Returns the number of used digits.
template<unsigned _uMaxDigits = 1024UL>
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.

Parameters:
_liLeftLeft operand.
_liRightRight operand.
_liResultResult.
template<unsigned _uMaxDigits = 1024UL>
template<typename _tType >
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.

Parameters:
_ptStringThe output string.
_ui32MaxLenThe maximum number of characters to print. Ignored if _ptString is NULL.
_ui32RadixThe radix used for printing.
Returns:
Returns the number of characters printed (not including the NULL character) or the number of characters needed to print the whole number (including the NULL character).

The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator