zeus::TInt Class Reference

#include <Int.h>

Inheritance diagram for zeus::TInt:

zeus::TZValueType< Int > zeus::TZObject zeus::IZUnknown

List of all members.

Public Member Functions

 TInt ()
 TInt (Int iValue)
 TInt (const TInt &rIn)
virtual ~TInt ()
void factorize (IMap< Int, Int > &rFactors) const
TString format (Uint uiLeadingZeros) const
Int getDigitCount (Uint uiNumBase=10) const
Int64 getFactorial () const
bool isPrime () const
TString toBinary (bool bTrimZeros=false) const
TString toHex (bool bTrimZeros=false) const

Static Public Member Functions

static void factorize (Int iValue, IMap< Int, Int > &rFactors)
static Int getDigitCount (Int iValue, Uint uiNumBase)
static Int64 getFactorial (Int iVal)
static bool isPrime (Int iValue)
static Int log2 (Int iValue)
static Int randomInt (Int iFrom, Int iTo)
static Int8 randomInt8 ()
static Int8 randomInt8 (Int8 cFrom, Int8 cTo)
static Int16 randomInt16 ()
static Int16 randomInt16 (Int16 lFrom, Int16 lTo)
static Int32 randomInt32 ()
static Int32 randomInt32 (Int32 lFrom, Int32 lTo)
static Int64 randomInt64 ()
static Int64 randomInt64 (const Int64 &rldFrom, const Int64 &rldTo)

Static Public Attributes

static const Int8 MaxInt8 = CHAR_MAX
static const Int8 MinInt8 = CHAR_MIN
static const Int16 MaxInt16 = SHRT_MAX
static const Int16 MinInt16 = SHRT_MIN
static const Int32 MaxInt32 = LONG_MAX
static const Int32 MinInt32 = LONG_MIN
static const Int64 MaxInt64 = _I64_MAX
static const Int64 MinInt64 = _I64_MIN
static const Uint8 MaxUint8 = UCHAR_MAX
static const Uint16 MaxUint16 = USHRT_MAX
static const Uint32 MaxUint32 = ULONG_MAX
static const Uint64 MaxUint64 = _UI64_MAX


Detailed Description

This class implements a wrapper for int-values

Constructor & Destructor Documentation

TInt::TInt (  ) 

Creates an empty Int-Object

TInt::TInt ( Int  iValue  ) 

Creates a Int-Object

Parameters:
iValue : Initial value

TInt::TInt ( const TInt rIn  ) 

copy constructor

TInt::~TInt (  )  [virtual]

Destroys the int object


Member Function Documentation

void zeus::TInt::factorize ( IMap< Int, Int > &  rFactors  )  const [inline]

factorizes the number and returns a map containing the factor (key) and its potential (value).

TString TInt::format ( Uint  uiLeadingZeros  )  const

This converts the int value into a string

Parameters:
uiLeadingZeros : How many leading zeros the formated output must have
Returns:
return of the formated output

Int zeus::TInt::getDigitCount ( Uint  uiNumBase = 10  )  const [inline]

Returns the number of digits representing this number.

Int64 zeus::TInt::getFactorial (  )  const [inline]

Returns the factorial of a number such as 7! = 1*2*3 ..*7

bool zeus::TInt::isPrime (  )  const [inline]

Checks if a number is prime

TString zeus::TInt::toBinary ( bool  bTrimZeros = false  )  const [inline]

This converts the int-value into the binary notation.

Parameters:
bTrimZeros : if this flag is set it will trim all leading zeros 0x000011010 -> 0x11010

TString zeus::TInt::toHex ( bool  bTrimZeros = false  )  const [inline]

This converts the int-value into the hex notation.

Parameters:
bTrimZeros : if this flag is set it will trim all leading zeros 0x0000FFA2 -> 0xFFA2

void TInt::factorize ( Int  iValue,
IMap< Int, Int > &  rFactors 
) [static]

factorizes the number and returns a map containing the factor (key) and its potential (value).

Parameters:
iValue : Number to factorize
rFactors : return value. Map contains the factors (key) and the potentials (value of map)

Int TInt::getDigitCount ( Int  iValue,
Uint  uiNumBase 
) [static]

returns the number of digits to show the number in a specific base of numbers (such as decimal, binary etc.). Note that this method will not return any digit (space) used for signs. This method returns the digits in a mathematical way (not space needed).

Parameters:
iValue : Number to check
iNumBase : Base of number system
Returns:
number of digits

Int64 TInt::getFactorial ( Int  iVal  )  [static]

Returns the factorial of a number. Note that this function can only handle n up to 20

Parameters:
iVal : number n
Returns:
n!

bool TInt::isPrime ( Int  iValue  )  [static]

checks if a number is prime

Parameters:
iValue : Number to check. Note that all negative value are rejected by this method. If iValue equals 0 or 1 the method will return false.
Return values:
true : Number is prime
false,: Number is not prime

Int TInt::log2 ( Int  iValue  )  [static]

A fast way to get the logarithm to the base of 2

Int zeus::TInt::randomInt ( Int  iFrom,
Int  iTo 
) [inline, static]

Returns a random integer number, which is between iFrom and iTo

Parameters:
iFrom : lower limit
iTo :upper limit
Returns:
random number

Int8 zeus::TInt::randomInt8 (  )  [inline, static]

returns a random number of int8 values

Int8 zeus::TInt::randomInt8 ( Int8  cFrom,
Int8  cTo 
) [inline, static]

returns a random number of int8 values

Parameters:
cFrom : lower limit
cTo : upper limit

Int16 zeus::TInt::randomInt16 (  )  [inline, static]

returns a random number of int16 values

Int16 zeus::TInt::randomInt16 ( Int16  sFrom,
Int16  sTo 
) [inline, static]

returns a random number of int16 values

Parameters:
sFrom : lower limit
sTo : upper limit

Int32 zeus::TInt::randomInt32 (  )  [inline, static]

returns a random number of int32 values

Int32 zeus::TInt::randomInt32 ( Int32  lFrom,
Int32  lTo 
) [inline, static]

returns a random number of int32 values

Parameters:
lFrom : lower limit
lTo : upper limit

Int64 zeus::TInt::randomInt64 (  )  [inline, static]

returns a random number of int64 values

Int64 zeus::TInt::randomInt64 ( const Int64 rldFrom,
const Int64 rldTo 
) [inline, static]

Returns a random 64 bit integer number, which is between ldFrom and ldTo

Parameters:
ldFrom : lower limit
ldTo :upper limit
Returns:
random number


Member Data Documentation

const Int8 TInt::MaxInt8 = CHAR_MAX [static]

const Int8 TInt::MinInt8 = CHAR_MIN [static]

const Int16 TInt::MaxInt16 = SHRT_MAX [static]

const Int16 TInt::MinInt16 = SHRT_MIN [static]

const Int32 TInt::MaxInt32 = LONG_MAX [static]

const Int32 TInt::MinInt32 = LONG_MIN [static]

const Int64 TInt::MaxInt64 = _I64_MAX [static]

const Int64 TInt::MinInt64 = _I64_MIN [static]

const Uint8 TInt::MaxUint8 = UCHAR_MAX [static]

const Uint16 TInt::MaxUint16 = USHRT_MAX [static]

const Uint32 TInt::MaxUint32 = ULONG_MAX [static]

const Uint64 TInt::MaxUint64 = _UI64_MAX [static]


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


Written by Benjamin Hadorn http://www.xatlantis.ch.
Last change made on Wed Oct 28 21:42:34 2009