Public Member Functions | Static Public Member Functions | Static Public Attributes

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, bool bAddPreamble=true) const
TString toHex (bool bTrimZeros=false, bool bAddPreamble=true) const

Static Public Member Functions

static Int convertBool (bool b)
 Convert a bool to Int.
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 = Int8Max
static const Int8 MinInt8 = Int8Min
static const Int16 MaxInt16 = Int16Max
static const Int16 MinInt16 = Int16Min
static const Int32 MaxInt32 = Int32Max
static const Int32 MinInt32 = Int32Min
static const Int64 MaxInt64 = Int64Max
static const Int64 MinInt64 = Int64Min
static const Uint8 MaxUint8 = Uint8Max
static const Uint16 MaxUint16 = Uint16Max
static const Uint32 MaxUint32 = Uint32Max
static const Uint64 MaxUint64 = Uint64Max

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

static Int zeus::TInt::convertBool ( bool  b ) [inline, static]

Convert a bool to Int.

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).

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)
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.

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
uiNumBase: Base of number system
Returns:
number of digits
Int64 zeus::TInt::getFactorial (  ) const [inline]

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

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 zeus::TInt::isPrime (  ) const [inline]

Checks if a number is prime

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
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 ( const Int64 rldFrom,
const Int64 rldTo 
) [inline, static]

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

Parameters:
rldFrom: lower limit
rldTo:upper limit
Returns:
random number
Int64 zeus::TInt::randomInt64 (  ) [inline, static]

returns a random number of int64 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
Int8 zeus::TInt::randomInt8 (  ) [inline, static]

returns a random number of int8 values

TString zeus::TInt::toBinary ( bool  bTrimZeros = false,
bool  bAddPreamble = true 
) 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
bAddPreamble,:add the preamble "0b". Default is true.
TString zeus::TInt::toHex ( bool  bTrimZeros = false,
bool  bAddPreamble = true 
) 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
bAddPreamble,:add the preamble "0x". Default is true.

Member Data Documentation

const Int16 TInt::MaxInt16 = Int16Max [static]
const Int32 TInt::MaxInt32 = Int32Max [static]
const Int64 TInt::MaxInt64 = Int64Max [static]
const Int8 TInt::MaxInt8 = Int8Max [static]
const Uint16 TInt::MaxUint16 = Uint16Max [static]
const Uint32 TInt::MaxUint32 = Uint32Max [static]
const Uint64 TInt::MaxUint64 = Uint64Max [static]
const Uint8 TInt::MaxUint8 = Uint8Max [static]
const Int16 TInt::MinInt16 = Int16Min [static]
const Int32 TInt::MinInt32 = Int32Min [static]
const Int64 TInt::MinInt64 = Int64Min [static]
const Int8 TInt::MinInt8 = Int8Min [static]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


Written by Benjamin Hadorn http://www.xatlantis.ch.
Last change made on Sun Jan 22 2012 15:28:34