zeus::TFloat Class Reference

#include <Float.h>

Inheritance diagram for zeus::TFloat:

zeus::TZValueType< Float > zeus::TZObject zeus::IZUnknown

List of all members.

Public Types

enum  EFloatClass { etRegular = 0, etNaN = 1, etPosInfinity = 2, etNegInfinity = 3 }

Public Member Functions

 TFloat ()
 TFloat (const TFloat &rValue)
 TFloat (Float fValue)
 TFloat (const IString &rValue)
 ~TFloat ()
bool equals (Float fValue, Float fPrecision) const
Float round () const
Float roundEx (Float fPrecision) const
Float ceil () const
Float floor () const
Int roundInt () const
Int ceilInt () const
Int floorInt () const
Float exp () const
Float pow (const Float &rfExp) const
Float cos () const
Float sin () const
Float tan () const
Float acos () const
Float asin () const
Float atan () const
Float sqrt () const
Float ln () const
Float log (const Float &rfBase) const
TString format (Float fRoundPrecision=0, Uint uiTailingZeros=0, Uint uiLeadingZeros=1) const
bool isZero () const
bool isNonZero () const
bool isInfinity () const
bool isPosInfinity () const
bool isNegInfinity () const
bool isNaN () const
Float getFactorial () const
bool operator== (const TFloat &rValue) const
bool operator== (const Float fValue) const
bool operator!= (const TFloat &rValue) const
bool operator!= (const Float fValue) const

Static Public Member Functions

static bool equalsFloat (Float fValue1, Float fValue2, Float fPrecision=FLOAT_PRECISION)
static bool isZero (const Float &fValue, Float fPrecision=FLOAT_PRECISION)
static bool isNonPositive (const Float &f, Float fPrecision=FLOAT_PRECISION)
static bool isNonNegative (const Float &f, Float fPrecision=FLOAT_PRECISION)
static bool isNonZero (const Float &fValue, Float fPrecision=FLOAT_PRECISION)
static bool isPositive (const Float &fValue, Float fPrecision=FLOAT_PRECISION)
static bool isNegative (const Float &fValue, Float fPrecision=FLOAT_PRECISION)
static bool isGreater (const Float &rfValue1, const Float &rfValue2, const Float &rfPrecision=FLOAT_PRECISION)
static bool isGreaterEqual (const Float &rfValue1, const Float &rfValue2, const Float &rfPrecision=FLOAT_PRECISION)
static bool isLower (const Float &rfValue1, const Float &rfValue2, const Float &rfPrecision=FLOAT_PRECISION)
static bool isLowerEqual (const Float &rfValue1, const Float &rfValue2, const Float &rfPrecision=FLOAT_PRECISION)
static bool isInfinity (Float fValue)
static bool isNaN (Float fValue)
static EFloatClass getClassType (Float fValue)
static Float getFactorial (Float fVal)
static Float randomFloat (Float fFrom, Float fTo)
static Float32 randomFloat32 ()
static Float64 randomFloat64 ()

Static Public Attributes

static const Float NaN = 0.0 / 0.0
static const Float Infinity = 1.0 / 0.0
static const Float NegInfinity = -1.0/0.0
static const Float MaxValue64bit = DBL_MAX
static const Float MinValue64bit = DBL_MIN
static const Float MaxValue32bit = FLT_MAX
static const Float MinValue32bit = FLT_MIN

Static Protected Attributes

static Float m_fStaticPrecision = FLOAT_PRECISION


Detailed Description

This class implements usefull methods to modify float values
Todo:
: Redesign this class for Float typedef. Select the correct API functions according the Float type (32, 64 or 80 bits)

Member Enumeration Documentation

Float class type

Enumerator:
etRegular 
etNaN 
etPosInfinity 
etNegInfinity 


Constructor & Destructor Documentation

zeus::TFloat::TFloat (  )  [inline]

Creates an empty float object

zeus::TFloat::TFloat ( const TFloat rValue  )  [inline]

Creates a float object out of an other float object

zeus::TFloat::TFloat ( Float  fValue  )  [inline]

Creates a float object out of an float

zeus::TFloat::TFloat ( const IString rValue  )  [inline]

Creates a float object out of a string value

zeus::TFloat::~TFloat (  )  [inline]

Destroys the float value


Member Function Documentation

bool zeus::TFloat::equals ( Float  fValue,
Float  fPrecision 
) const [inline]

this method checks if a float value is equal to this float object

Parameters:
fValue : Value to check
fPrecision : How precise the check will be
Return values:
true : double values are equal within the precision
false,: Values are not equal

Float zeus::TFloat::round (  )  const [inline]

Float zeus::TFloat::roundEx ( Float  fPrecision  )  const [inline]

Float zeus::TFloat::ceil (  )  const [inline]

Float zeus::TFloat::floor (  )  const [inline]

Int zeus::TFloat::roundInt (  )  const [inline]

Int zeus::TFloat::ceilInt (  )  const [inline]

Int zeus::TFloat::floorInt (  )  const [inline]

Float zeus::TFloat::exp (  )  const [inline]

Float zeus::TFloat::pow ( const Float &  rfExp  )  const [inline]

Float zeus::TFloat::cos (  )  const [inline]

Float zeus::TFloat::sin (  )  const [inline]

Float zeus::TFloat::tan (  )  const [inline]

Float zeus::TFloat::acos (  )  const [inline]

Float zeus::TFloat::asin (  )  const [inline]

Float zeus::TFloat::atan (  )  const [inline]

Float zeus::TFloat::sqrt (  )  const [inline]

Float zeus::TFloat::ln (  )  const [inline]

Float zeus::TFloat::log ( const Float &  rfBase  )  const [inline]

TString TFloat::format ( Float  fRoundPrecision = 0,
Uint  uiTailingZeros = 0,
Uint  uiLeadingZeros = 1 
) const

Formats the float object and returns the string. The format is specified by three parameters:

Parameters:
dRoundPrecision : Rounding precision. 0 means no rounding (default) see TMath::roundEx for more informations.
ulTailingZeros : Tailing zeros (from decimal point). Default is 0.
ulLeadingZeros : Leading zeros (from decimal point). Default is 1
Returns:
formated string output

bool zeus::TFloat::isZero (  )  const [inline]

Checks if the float number is zero using a precision value

Parameters:
fPrecision : precision value
Return values:
true : value is zero within the given precision
false,: value is not zero

bool zeus::TFloat::isNonZero (  )  const [inline]

Checks if the float number is non zero using a precision value

Parameters:
fPrecision : precision value
Return values:
true : value is non zero within the given precision
false,: value is zero

bool zeus::TFloat::isInfinity (  )  const [inline]

Checks if the float object is infinity (positive or negative)

Return values:
true : floating number is infinity
false,: not infinity

bool zeus::TFloat::isPosInfinity (  )  const [inline]

returns true if the value is positive and infinity

bool zeus::TFloat::isNegInfinity (  )  const [inline]

returns true if the value is negative and infinity

bool zeus::TFloat::isNaN (  )  const [inline]

Checks if the float object is not a number

Return values:
true : not a number
false,: a number

Float zeus::TFloat::getFactorial (  )  const [inline]

This factorial method uses the Stirling's approximation (Formula from wikipedia)

bool zeus::TFloat::operator== ( const TFloat rValue  )  const [inline]

equals operator to check if two floats are the same

bool zeus::TFloat::operator== ( const Float  fValue  )  const [inline]

equals operator to check if two floats are the same

Reimplemented from zeus::TZValueType< Float >.

bool zeus::TFloat::operator!= ( const TFloat rValue  )  const [inline]

not-equals operator to check if two floats are not the same

bool zeus::TFloat::operator!= ( const Float  fValue  )  const [inline]

not-equals operator to check if two floats are not the same

Reimplemented from zeus::TZValueType< Float >.

bool zeus::TFloat::equalsFloat ( Float  fValue1,
Float  fValue2,
Float  fPrecision = FLOAT_PRECISION 
) [inline, static]

Checks if two float values are the same

Parameters:
fValue1 : Value to check
fValue2 : Value to check
fPrecision : How precise the check will be
Return values:
true : double values are equal within the precision
false,: Values are not equal

bool zeus::TFloat::isZero ( const Float &  fValue,
Float  fPrecision = FLOAT_PRECISION 
) [inline, static]

Checks if a float number is zero using a precision value

Parameters:
fValue : Value to check
fPrecision : precision value
Return values:
true : value is zero within the given precision
false,: value is not zero

bool zeus::TFloat::isNonPositive ( const Float &  f,
Float  fPrecision = FLOAT_PRECISION 
) [inline, static]

negativity of a float value.

Parameters:
f [IN]: Float value.
fPrecision [IN]: Numerical tolerance.
Return values:
true : f is numerically negative or zero.
false : f is numerically positive.

bool zeus::TFloat::isNonNegative ( const Float &  f,
Float  fPrecision = FLOAT_PRECISION 
) [inline, static]

positivity of a float value.

Parameters:
f [IN]: Float value.
fPrecision [IN]: Numerical tolerance.
Return values:
true : f is numerically positive or zero.
false : f is numerically negative.

static bool zeus::TFloat::isNonZero ( const Float &  fValue,
Float  fPrecision = FLOAT_PRECISION 
) [inline, static]

static bool zeus::TFloat::isPositive ( const Float &  fValue,
Float  fPrecision = FLOAT_PRECISION 
) [inline, static]

static bool zeus::TFloat::isNegative ( const Float &  fValue,
Float  fPrecision = FLOAT_PRECISION 
) [inline, static]

static bool zeus::TFloat::isGreater ( const Float &  rfValue1,
const Float &  rfValue2,
const Float &  rfPrecision = FLOAT_PRECISION 
) [inline, static]

static bool zeus::TFloat::isGreaterEqual ( const Float &  rfValue1,
const Float &  rfValue2,
const Float &  rfPrecision = FLOAT_PRECISION 
) [inline, static]

static bool zeus::TFloat::isLower ( const Float &  rfValue1,
const Float &  rfValue2,
const Float &  rfPrecision = FLOAT_PRECISION 
) [inline, static]

static bool zeus::TFloat::isLowerEqual ( const Float &  rfValue1,
const Float &  rfValue2,
const Float &  rfPrecision = FLOAT_PRECISION 
) [inline, static]

bool TFloat::isInfinity ( Float  fValue  )  [static]

Checks if the float is infinity (positive or negative)

Return values:
true : floating number is infinity
false,: not infinity

bool TFloat::isNaN ( Float  fValue  )  [static]

Checks if the float is not a number

Return values:
true : not a number
false,: a number

TFloat::EFloatClass TFloat::getClassType ( Float  fValue  )  [static]

Checks if the float is not a number

Return values:
true : not a number
false,: a number

Float TFloat::getFactorial ( Float  fVal  )  [static]

This factorial method uses the Srinivasa Ramanujan's approximation (Formula from wikipedia)

Float zeus::TFloat::randomFloat ( Float  fFrom,
Float  fTo 
) [inline, static]

Returns a random float number, which is between from and to

Parameters:
fFrom : lower limit
fTo :upper limit
Returns:
random number

Float32 zeus::TFloat::randomFloat32 (  )  [inline, static]

returns a random number of float32 values

Float64 zeus::TFloat::randomFloat64 (  )  [inline, static]

returns a random number of float64 values


Member Data Documentation

const Float TFloat::NaN = 0.0 / 0.0 [static]

const Float TFloat::Infinity = 1.0 / 0.0 [static]

const Float TFloat::NegInfinity = -1.0/0.0 [static]

const Float TFloat::MaxValue64bit = DBL_MAX [static]

const Float TFloat::MinValue64bit = DBL_MIN [static]

const Float TFloat::MaxValue32bit = FLT_MAX [static]

const Float TFloat::MinValue32bit = FLT_MIN [static]

Float TFloat::m_fStaticPrecision = FLOAT_PRECISION [static, protected]


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