TInteger Class Reference

class TInteger

Abstract base class defining the interface for handling and manipulating big integers.

TInteger is capable of representing both negative and positive integers with an absolute value of less than 2^32^(2^32). To create an integer look at RInteger . TInteger defines an interface for the RInteger implementation - it is not intended that TIntegers be copied or assigned from other TIntegers. On EKA1 platforms, this is possible, but it should be avoided.

RInteger

Public Member Functions
IMPORT_C TBool Bit ( TUint )
IMPORT_C TUint BitCount (void)
IMPORT_C HBufC8 * BufferLC ()
IMPORT_C HBufC8 * BufferWithNoTruncationLC ()
IMPORT_C TUint ByteCount (void)
IMPORT_C TInt ConvertToLongL (void)
IMPORT_C void CopyL (const TInteger &, TBool )
IMPORT_C void CopyL (const TInt , TBool )
IMPORT_C RInteger DividedByL (const TInteger &)
IMPORT_C RInteger DividedByL ( TUint )
IMPORT_C RInteger ExponentiateL (const TInteger &)
IMPORT_C RInteger GCDL (const TInteger &)
IMPORT_C RInteger InverseModL (const TInteger &)
TBool IsEven ()
TBool IsNegative ()
TBool IsOdd ()
TBool IsPositive ()
IMPORT_C TBool IsPrimeL (void)
TBool IsZero ()
IMPORT_C RInteger MinusL (const TInteger &)
IMPORT_C RInteger ModularExponentiateL (const TInteger &, const TInteger &, const TInteger &)
IMPORT_C RInteger ModularMultiplyL (const TInteger &, const TInteger &, const TInteger &)
IMPORT_C RInteger ModuloL (const TInteger &)
IMPORT_C TUint ModuloL ( TUint )
IMPORT_C void Negate (void)
TBool NotNegative ()
TBool NotPositive ()
TBool NotZero ()
IMPORT_C const TInteger & One (void)
IMPORT_C RInteger PlusL (const TInteger &)
IMPORT_C void Set (const RInteger &)
IMPORT_C void SetBit ( TUint )
IMPORT_C TInt SignedCompare (const TInteger &)
IMPORT_C TInt SignedCompare ( TInt )
IMPORT_C RInteger SquaredL (void)
IMPORT_C RInteger TimesL (const TInteger &)
IMPORT_C const TInteger & Two (void)
IMPORT_C TInt UnsignedCompare (const TInteger &)
IMPORT_C TUint WordCount (void)
IMPORT_C const TInteger & Zero (void)
IMPORT_C TBool operator! ()
TBool operator!= (const TInteger &)
TBool operator!= ( TInt )
IMPORT_C TInteger & operator%= (const TInteger &)
IMPORT_C TInteger & operator%= ( TInt )
IMPORT_C TInteger & operator*= (const TInteger &)
IMPORT_C TInteger & operator*= ( TInt )
IMPORT_C TInteger & operator++ ()
IMPORT_C TInteger & operator+= (const TInteger &)
IMPORT_C TInteger & operator+= ( TInt )
IMPORT_C TInteger & operator-- ()
IMPORT_C TInteger & operator-= (const TInteger &)
IMPORT_C TInteger & operator-= ( TInt )
IMPORT_C TInteger & operator/= (const TInteger &)
IMPORT_C TInteger & operator/= ( TInt )
TBool operator< (const TInteger &)
TBool operator< ( TInt )
IMPORT_C TInteger & operator<<= ( TUint )
TBool operator<= (const TInteger &)
TBool operator<= ( TInt )
TBool operator== (const TInteger &)
TBool operator== ( TInt )
TBool operator> (const TInteger &)
TBool operator> ( TInt )
TBool operator>= (const TInteger &)
TBool operator>= ( TInt )
IMPORT_C TInteger & operator>>= ( TUint )
Protected Member Functions
TInteger (void)
void CleanGrowL ( TUint )
void CleanNewL ( TUint )
void CleanResizeL ( TUint )
void Construct (const TDesC8 &)
void Construct (const TInteger &)
void Construct ( TInt )
void Construct ( TUint )
void ConstructStack ( TUint , TUint )
void ConstructStack ( TUint , const TInteger &)
TInt ConvertToLong (void)
TUint ConvertToUnsignedLong (void)
void CreateNewL ( TUint )
void DivideL ( RInteger &, RInteger &, const TInteger &, const TInteger &)
void DivideL ( TUint &, RInteger &, const TInteger &, TUint )
TBool IsConvertableToLong (void)
TBool IsHeapBased (void)
TBool IsStackBased (void)
TUint Modulo (const TInteger &, TUint )
RInteger PositiveAddL (const TInteger &, const TInteger &)
void PositiveDivide ( TUint &, TInteger &, const TInteger &, TUint )
void PositiveDivideL ( RInteger &, RInteger &, const TInteger &, const TInteger &)
RInteger PositiveMultiplyL (const TInteger &, const TInteger &)
RInteger PositiveSubtractL (const TInteger &, const TInteger &)
void PrimeRandomizeL ( TUint , TRandomAttribute )
TUint *const Ptr (void)
void RandomizeL ( TUint , TRandomAttribute )
void RandomizeL (const TInteger &, const TInteger &)
void SetHeapBased (void)
void SetPtr ( TUint *)
void SetSign ( TSign )
void SetSize ( TUint )
void SetStackBased (void)
TSign Sign (void)
TUint Size (void)
TBool SmallPrimeRandomizeL (void)
Private Member Functions
TInteger (const TInteger &)
TInteger & operator= (const TInteger &)
Public Member Enumerations
enum TRandomAttribute { EAllBitsRandom  = 0, ETopBitSet  = 1, ETop2BitsSet  = 2 }
Protected Member Enumerations
enum TSign { EPositive  = 0, ENegative  = 1 }
Protected Attributes
TUint iPtr
TUint iSize

Constructor & Destructor Documentation

TInteger(void)

IMPORT_C TInteger ( void ) [protected]

Parameters

void

TInteger(const TInteger &)

TInteger ( const TInteger & aInteger ) [private]

Parameters

const TInteger & aInteger

Member Functions Documentation

Bit(TUint)

IMPORT_C TBool Bit ( TUint aBitPos ) const

Parameters

TUint aBitPos

BitCount(void)

IMPORT_C TUint BitCount ( void ) const

Get the number of bits required to represent this RInteger .

Parameters

void

BufferLC()

IMPORT_C HBufC8 * BufferLC ( ) const

Creates a new buffer containing the big-endian binary representation of this integer.

Note that it does not support the exporting of negative integers.

leave
KErrNegativeExportNotSupported If this instance is a negative integer.

BufferWithNoTruncationLC()

IMPORT_C HBufC8 * BufferWithNoTruncationLC ( ) const

ByteCount(void)

IMPORT_C TUint ByteCount ( void ) const

Gets the number of bytes required to represent this RInteger .

Parameters

void

CleanGrowL(TUint)

void CleanGrowL ( TUint aNewSize ) [protected]

Parameters

TUint aNewSize

CleanNewL(TUint)

void CleanNewL ( TUint aNewSize ) [protected]

Parameters

TUint aNewSize

CleanResizeL(TUint)

void CleanResizeL ( TUint aNewSize ) [protected]

Parameters

TUint aNewSize

Construct(const TDesC8 &)

void Construct ( const TDesC8 & aValue ) [protected]

Parameters

const TDesC8 & aValue

Construct(const TInteger &)

void Construct ( const TInteger & aInteger ) [protected]

Parameters

const TInteger & aInteger

Construct(TInt)

void Construct ( TInt aInteger ) [protected]

Parameters

TInt aInteger

Construct(TUint)

void Construct ( TUint aInteger ) [protected]

Parameters

TUint aInteger

ConstructStack(TUint, TUint)

void ConstructStack ( TUint aWords,
TUint aInteger
) [protected]

Parameters

TUint aWords
TUint aInteger

ConstructStack(TUint, const TInteger &)

void ConstructStack ( TUint aWords,
const TInteger & aInteger
) [protected]

Parameters

TUint aWords
const TInteger & aInteger

ConvertToLong(void)

TInt ConvertToLong ( void ) const [protected]

Parameters

void

ConvertToLongL(void)

IMPORT_C TInt ConvertToLongL ( void ) const

Parameters

void

ConvertToUnsignedLong(void)

TUint ConvertToUnsignedLong ( void ) const [protected, inline]

Parameters

void

CopyL(const TInteger &, TBool)

IMPORT_C void CopyL ( const TInteger & aInteger,
TBool aAllowShrink = ETrue
)

Parameters

const TInteger & aInteger
TBool aAllowShrink = ETrue

CopyL(const TInt, TBool)

IMPORT_C void CopyL ( const TInt aInteger,
TBool aAllowShrink = ETrue
)

Parameters

const TInt aInteger
TBool aAllowShrink = ETrue

CreateNewL(TUint)

void CreateNewL ( TUint aNewSize ) [protected]

Parameters

TUint aNewSize

DivideL(RInteger &, RInteger &, const TInteger &, const TInteger &)

void DivideL ( RInteger & aRemainder,
RInteger & aQuotient,
const TInteger & aDividend,
const TInteger & aDivisor
) const [protected]

Parameters

RInteger & aRemainder
RInteger & aQuotient
const TInteger & aDividend
const TInteger & aDivisor

DivideL(TUint &, RInteger &, const TInteger &, TUint)

void DivideL ( TUint & aRemainder,
RInteger & aQoutient,
const TInteger & aDividend,
TUint aDivisor
) const [protected]

Parameters

TUint & aRemainder
RInteger & aQoutient
const TInteger & aDividend
TUint aDivisor

DividedByL(const TInteger &)

IMPORT_C RInteger DividedByL ( const TInteger & aOperand ) const

Parameters

const TInteger & aOperand

DividedByL(TUint)

IMPORT_C RInteger DividedByL ( TUint aOperand ) const

Parameters

TUint aOperand

ExponentiateL(const TInteger &)

IMPORT_C RInteger ExponentiateL ( const TInteger & aExponent ) const

Parameters

const TInteger & aExponent

GCDL(const TInteger &)

IMPORT_C RInteger GCDL ( const TInteger & aOperand ) const

Parameters

const TInteger & aOperand

InverseModL(const TInteger &)

IMPORT_C RInteger InverseModL ( const TInteger & aMod ) const

Parameters

const TInteger & aMod

IsConvertableToLong(void)

TBool IsConvertableToLong ( void ) const [protected]

Parameters

void

IsEven()

TBool IsEven ( ) const [inline]

IsHeapBased(void)

TBool IsHeapBased ( void ) const [protected, inline]

Parameters

void

IsNegative()

TBool IsNegative ( ) const [inline]

IsOdd()

TBool IsOdd ( ) const [inline]

IsPositive()

TBool IsPositive ( ) const [inline]

IsPrimeL(void)

IMPORT_C TBool IsPrimeL ( void ) const

Parameters

void

IsStackBased(void)

TBool IsStackBased ( void ) const [protected, inline]

Parameters

void

IsZero()

TBool IsZero ( ) const [inline]

MinusL(const TInteger &)

IMPORT_C RInteger MinusL ( const TInteger & aOperand ) const

Parameters

const TInteger & aOperand

ModularExponentiateL(const TInteger &, const TInteger &, const TInteger &)

IMPORT_C RInteger ModularExponentiateL ( const TInteger & aBase,
const TInteger & aExp,
const TInteger & aMod
) [static]

Parameters

const TInteger & aBase
const TInteger & aExp
const TInteger & aMod

ModularMultiplyL(const TInteger &, const TInteger &, const TInteger &)

IMPORT_C RInteger ModularMultiplyL ( const TInteger & aA,
const TInteger & aB,
const TInteger & aModulus
) [static]

Parameters

const TInteger & aA
const TInteger & aB
const TInteger & aModulus

Modulo(const TInteger &, TUint)

TUint Modulo ( const TInteger & aDividend,
TUint aDivisor
) const [protected]

Parameters

const TInteger & aDividend
TUint aDivisor

ModuloL(const TInteger &)

IMPORT_C RInteger ModuloL ( const TInteger & aOperand ) const

Parameters

const TInteger & aOperand

ModuloL(TUint)

IMPORT_C TUint ModuloL ( TUint aOperand ) const

Parameters

TUint aOperand

Negate(void)

IMPORT_C void Negate ( void )

Parameters

void

NotNegative()

TBool NotNegative ( ) const [inline]

NotPositive()

TBool NotPositive ( ) const [inline]

NotZero()

TBool NotZero ( ) const [inline]

One(void)

IMPORT_C const TInteger & One ( void ) [static]

Gets the TInteger that represents one

Parameters

void

PlusL(const TInteger &)

IMPORT_C RInteger PlusL ( const TInteger & aOperand ) const

Parameters

const TInteger & aOperand

PositiveAddL(const TInteger &, const TInteger &)

RInteger PositiveAddL ( const TInteger & aA,
const TInteger & aB
) const [protected]

Parameters

const TInteger & aA
const TInteger & aB

PositiveDivide(TUint &, TInteger &, const TInteger &, TUint)

void PositiveDivide ( TUint & aRemainder,
TInteger & aQoutient,
const TInteger & aDividend,
TUint aDivisor
) const [protected]

Parameters

TUint & aRemainder
TInteger & aQoutient
const TInteger & aDividend
TUint aDivisor

PositiveDivideL(RInteger &, RInteger &, const TInteger &, const TInteger &)

void PositiveDivideL ( RInteger & aRemainder,
RInteger & aQuotient,
const TInteger & aDividend,
const TInteger & aDivisor
) const [protected]

Parameters

RInteger & aRemainder
RInteger & aQuotient
const TInteger & aDividend
const TInteger & aDivisor

PositiveMultiplyL(const TInteger &, const TInteger &)

RInteger PositiveMultiplyL ( const TInteger & aA,
const TInteger & aB
) const [protected]

Parameters

const TInteger & aA
const TInteger & aB

PositiveSubtractL(const TInteger &, const TInteger &)

RInteger PositiveSubtractL ( const TInteger & aA,
const TInteger & aB
) const [protected]

Parameters

const TInteger & aA
const TInteger & aB

PrimeRandomizeL(TUint, TRandomAttribute)

void PrimeRandomizeL ( TUint aBits,
TRandomAttribute aAttr
) [protected]

Parameters

TUint aBits
TRandomAttribute aAttr

Ptr(void)

TUint *const Ptr ( void ) const [protected, inline]

Parameters

void

RandomizeL(TUint, TRandomAttribute)

void RandomizeL ( TUint aBits,
TRandomAttribute aAttr
) [protected]

Parameters

TUint aBits
TRandomAttribute aAttr

RandomizeL(const TInteger &, const TInteger &)

void RandomizeL ( const TInteger & aMin,
const TInteger & aMax
) [protected]

Parameters

const TInteger & aMin
const TInteger & aMax

Set(const RInteger &)

IMPORT_C void Set ( const RInteger & aInteger )

Parameters

const RInteger & aInteger

SetBit(TUint)

IMPORT_C void SetBit ( TUint aBitPos )

Parameters

TUint aBitPos

SetHeapBased(void)

void SetHeapBased ( void ) [protected, inline]

Parameters

void

SetPtr(TUint *)

void SetPtr ( TUint * aPtr ) [protected, inline]

Parameters

TUint * aPtr

SetSign(TSign)

void SetSign ( TSign aSign ) [protected, inline]

Parameters

TSign aSign

SetSize(TUint)

void SetSize ( TUint aSize ) [protected, inline]

Parameters

TUint aSize

SetStackBased(void)

void SetStackBased ( void ) [protected, inline]

Parameters

void

Sign(void)

TSign Sign ( void ) const [protected, inline]

Parameters

void

SignedCompare(const TInteger &)

IMPORT_C TInt SignedCompare ( const TInteger & aThat ) const

Parameters

const TInteger & aThat

SignedCompare(TInt)

IMPORT_C TInt SignedCompare ( TInt aThat ) const

Parameters

TInt aThat

Size(void)

TUint Size ( void ) const [protected, inline]

Parameters

void

SmallPrimeRandomizeL(void)

TBool SmallPrimeRandomizeL ( void ) [protected]

Parameters

void

SquaredL(void)

IMPORT_C RInteger SquaredL ( void ) const

Parameters

void

TimesL(const TInteger &)

IMPORT_C RInteger TimesL ( const TInteger & aOperand ) const

Parameters

const TInteger & aOperand

Two(void)

IMPORT_C const TInteger & Two ( void ) [static]

Gets the TInteger that represents two

Parameters

void

UnsignedCompare(const TInteger &)

IMPORT_C TInt UnsignedCompare ( const TInteger & aThat ) const

Parameters

const TInteger & aThat

WordCount(void)

IMPORT_C TUint WordCount ( void ) const

Gets the number of words required to represent this RInteger .

Parameters

void

Zero(void)

IMPORT_C const TInteger & Zero ( void ) [static]

Gets the TInteger that represents zero

Parameters

void

operator!()

IMPORT_C TBool operator! ( ) const

operator!=(const TInteger &)

TBool operator!= ( const TInteger & aInteger ) const [inline]

Parameters

const TInteger & aInteger

operator!=(TInt)

TBool operator!= ( TInt aInteger ) const [inline]

Parameters

TInt aInteger

operator%=(const TInteger &)

IMPORT_C TInteger & operator%= ( const TInteger & aOperand )

Parameters

const TInteger & aOperand

operator%=(TInt)

IMPORT_C TInteger & operator%= ( TInt aOperand )

Parameters

TInt aOperand

operator*=(const TInteger &)

IMPORT_C TInteger & operator*= ( const TInteger & aOperand )

Parameters

const TInteger & aOperand

operator*=(TInt)

IMPORT_C TInteger & operator*= ( TInt aOperand )

Parameters

TInt aOperand

operator++()

IMPORT_C TInteger & operator++ ( )

operator+=(const TInteger &)

IMPORT_C TInteger & operator+= ( const TInteger & aOperand )

Parameters

const TInteger & aOperand

operator+=(TInt)

IMPORT_C TInteger & operator+= ( TInt aOperand )

Parameters

TInt aOperand

operator--()

IMPORT_C TInteger & operator-- ( )

operator-=(const TInteger &)

IMPORT_C TInteger & operator-= ( const TInteger & aOperand )

Parameters

const TInteger & aOperand

operator-=(TInt)

IMPORT_C TInteger & operator-= ( TInt aOperand )

Parameters

TInt aOperand

operator/=(const TInteger &)

IMPORT_C TInteger & operator/= ( const TInteger & aOperand )

Parameters

const TInteger & aOperand

operator/=(TInt)

IMPORT_C TInteger & operator/= ( TInt aOperand )

Parameters

TInt aOperand

operator<(const TInteger &)

TBool operator< ( const TInteger & aInteger ) const [inline]

Parameters

const TInteger & aInteger

operator<(TInt)

TBool operator< ( TInt aInteger ) const [inline]

Parameters

TInt aInteger

operator<<=(TUint)

IMPORT_C TInteger & operator<<= ( TUint aBits )

Parameters

TUint aBits

operator<=(const TInteger &)

TBool operator<= ( const TInteger & aInteger ) const [inline]

Parameters

const TInteger & aInteger

operator<=(TInt)

TBool operator<= ( TInt aInteger ) const [inline]

Parameters

TInt aInteger

operator=(const TInteger &)

TInteger & operator= ( const TInteger & aInteger ) [private]

Parameters

const TInteger & aInteger

operator==(const TInteger &)

TBool operator== ( const TInteger & aInteger ) const [inline]

Parameters

const TInteger & aInteger

operator==(TInt)

TBool operator== ( TInt aInteger ) const [inline]

Parameters

TInt aInteger

operator>(const TInteger &)

TBool operator> ( const TInteger & aInteger ) const [inline]

Parameters

const TInteger & aInteger

operator>(TInt)

TBool operator> ( TInt aInteger ) const [inline]

Parameters

TInt aInteger

operator>=(const TInteger &)

TBool operator>= ( const TInteger & aInteger ) const [inline]

Parameters

const TInteger & aInteger

operator>=(TInt)

TBool operator>= ( TInt aInteger ) const [inline]

Parameters

TInt aInteger

operator>>=(TUint)

IMPORT_C TInteger & operator>>= ( TUint aBits )

Parameters

TUint aBits

Member Enumerations Documentation

Enum TRandomAttribute

Enumerators

EAllBitsRandom = 0
ETopBitSet = 1
ETop2BitsSet = 2

Enum TSign

Enumerators

EPositive = 0
ENegative = 1

Member Data Documentation

TUint iPtr

TUint iPtr [protected]

TUint iSize

TUint iSize [protected]