TRealX Class Reference

#include <e32math.h>

class TRealX
Public Attributes
TUint16 iExp
TUint8 iFlag
TUint32 iMantHi
TUint32 iMantLo
TInt8 iSign
Public Member Enumerations
enumTRealXOrder { ELessThan, EEqual, EGreaterThan, EUnordered }
Public Member Functions
TRealX()
TRealX(TInt)
TRealX(TUint)
TRealX(TUint, TUint, TUint)
TRealX(const TInt64 &)
TRealX(TReal32)
TRealX(TReal64)
IMPORT_C TIntAdd(TRealX &, const TRealX &)
IMPORT_C TIntAddEq(const TRealX &)
IMPORT_C TRealXOrderCompare(const TRealX &)
IMPORT_C TIntDiv(TRealX &, const TRealX &)
IMPORT_C TIntDivEq(const TRealX &)
IMPORT_C TIntGetTReal(TReal32 &)
IMPORT_C TIntGetTReal(TReal64 &)
IMPORT_C TBoolIsFinite()
IMPORT_C TBoolIsInfinite()
IMPORT_C TBoolIsNaN()
IMPORT_C TBoolIsZero()
IMPORT_C TIntMod(TRealX &, const TRealX &)
IMPORT_C TIntModEq(const TRealX &)
IMPORT_C TIntMult(TRealX &, const TRealX &)
IMPORT_C TIntMultEq(const TRealX &)
IMPORT_C TIntSet(TInt)
IMPORT_C TIntSet(TUint)
IMPORT_C TIntSet(const TInt64 &)
IMPORT_C TIntSet(TReal32)
IMPORT_C TIntSet(TReal64)
IMPORT_C voidSetInfinite(TBool)
IMPORT_C voidSetNaN()
IMPORT_C voidSetZero(TBool)
IMPORT_C TIntSub(TRealX &, const TRealX &)
IMPORT_C TIntSubEq(const TRealX &)
IMPORT_Coperator TInt()
IMPORT_Coperator TInt64()
IMPORT_Coperator TReal32()
IMPORT_Coperator TReal64()
IMPORT_Coperator TUint()
TBool operator!=(const TRealX &)
IMPORT_C TRealXoperator%(const TRealX &)
IMPORT_C const TRealX &operator%=(const TRealX &)
IMPORT_C TRealXoperator*(const TRealX &)
IMPORT_C const TRealX &operator*=(const TRealX &)
IMPORT_C TRealXoperator+()
IMPORT_C TRealXoperator+(const TRealX &)
IMPORT_C TRealX &operator++()
IMPORT_C TRealXoperator++(TInt)
IMPORT_C const TRealX &operator+=(const TRealX &)
IMPORT_C TRealXoperator-()
IMPORT_C TRealXoperator-(const TRealX &)
IMPORT_C TRealX &operator--()
IMPORT_C TRealXoperator--(TInt)
IMPORT_C const TRealX &operator-=(const TRealX &)
IMPORT_C TRealXoperator/(const TRealX &)
IMPORT_C const TRealX &operator/=(const TRealX &)
TBool operator<(const TRealX &)
TBool operator<=(const TRealX &)
IMPORT_C TRealX &operator=(TInt)
IMPORT_C TRealX &operator=(TUint)
IMPORT_C TRealX &operator=(const TInt64 &)
IMPORT_C TRealX &operator=(TReal32)
IMPORT_C TRealX &operator=(TReal64)
TBool operator==(const TRealX &)
TBool operator>(const TRealX &)
TBool operator>=(const TRealX &)

Detailed Description

A class encapsulating an extended precision real value.

This class provides 64 bit precision and a dynamic range of approximately 1E-9863 to 1E+9863. All member functions are optimized for speed.

Member Attribute Documentation

iExp

TUint16 iExp

Exponent: biased by 32767, iExp=0 => zero, +65535 => infinity or NaN

iFlag

TUint8 iFlag

Flags: 0 for exact, 1 for rounded down, 2 for rounded up

iMantHi

TUint32 iMantHi

iMantLo

TUint32 iMantLo

The mantissa.

iSign

TInt8 iSign

The sign: 0 for +, 1 for -

Member Enumeration Documentation

Enum TRealXOrder

EnumeratorValueDescription
ELessThan1
EEqual2
EGreaterThan4
EUnordered8

Constructor & Destructor Documentation

TRealX ( )

IMPORT_CTRealX()

Constructs a default extended precision object.

This sets the value to zero.

TRealX ( TInt )

IMPORT_CTRealX(TIntaInt)

Constructs an extended precision object from a signed integer value.

TRealX ( TUint )

IMPORT_CTRealX(TUintaInt)

Constructs an extended precision object from an unsigned integer value.

TRealX ( TUint, TUint, TUint )

IMPORT_CTRealX(TUintaExp,
TUintaMantHi,
TUintaMantLo
)

Constructs an extended precision object from an explicit exponent and a 64 bit mantissa.

Parameters
aMantHiThe high order 32 bits of the 64 bit mantissa
aMantLoThe low order 32 bits of the 64 bit mantissa

TRealX ( const TInt64 & )

IMPORT_CTRealX(const TInt64 &aInt)

Constructs an extended precision object from a 64 bit integer.

TRealX ( TReal32 )

IMPORT_CTRealX(TReal32aReal)

Constructs an extended precision object from a single precision floating point number.

Parameters
aRealThe single precision floating point value.

TRealX ( TReal64 )

IMPORT_CTRealX(TReal64aReal)

Constructs an extended precision object from a double precision floating point number.

Parameters
aRealThe double precision floating point value.

Member Function Documentation

Add ( TRealX &, const TRealX & )

IMPORT_C TIntAdd(TRealX &aResult,
const TRealX &aVal
)const

Adds an extended precision value to this extended precision number.

Parameters
aResultOn return, a reference to an extended precision object containing the result of the operation.
aValThe extended precision value to be added.
Return Value
KErrNone, if the operation is successful; KErrOverflow, if the operation results in overflow; KErrUnderflow, if the operation results in underflow.

AddEq ( const TRealX & )

IMPORT_C TIntAddEq(const TRealX &aVal)

Adds an extended precision value to this extended precision number.

Parameters
aValThe extended precision value to be added.
Return Value
KErrNone, if the operation is successful; KErrOverflow,if the operation results in overflow; KErrUnderflow, if the operation results in underflow.

Compare ( const TRealX & )

IMPORT_C TRealXOrderCompare(const TRealX &aVal)const

Div ( TRealX &, const TRealX & )

IMPORT_C TIntDiv(TRealX &aResult,
const TRealX &aVal
)const

Divides this extended precision number by an extended precision value.

Parameters
aResultOn return, a reference to an extended precision object containing the result of the operation.
aValThe extended precision value to be used as the divisor.
Return Value
KErrNone, if the operation is successful; KErrOverflow, if the operation results in overflow; KErrUnderflow, if the operation results in underflow; KErrDivideByZero, if the divisor is zero.

DivEq ( const TRealX & )

IMPORT_C TIntDivEq(const TRealX &aVal)

Divides this extended precision number by an extended precision value.

Parameters
aValThe extended precision value to be used as the divisor.
Return Value
KErrNone, if the operation is successful; KErrOverflow, if the operation results in overflow; KErrUnderflow, if the operation results in underflow; KErrDivideByZero, if the divisor is zero.

GetTReal ( TReal32 & )

IMPORT_C TIntGetTReal(TReal32 &aVal)const

Extracts the extended precision value as a single precision floating point value.

Parameters
aValA reference to a single precision object which contains the result of the operation.
Return Value
KErrNone, if the operation is successful; KErrOverflow, if the operation results in overflow; KErrUnderflow, if the operation results in underflow.

GetTReal ( TReal64 & )

IMPORT_C TIntGetTReal(TReal64 &aVal)const

Extracts the extended precision value as a double precision floating point value.

Parameters
aValA reference to a double precision object which contains the result of the operation.
Return Value
KErrNone, if the operation is successful; KErrOverflow, if the operation results in overflow; KErrUnderflow, if the operation results in underflow.

IsFinite ( )

IMPORT_C TBoolIsFinite()const

Determines whether the extended precision value has a finite value.

Return Value
True, if the extended precision value is finite, false, if the value is 'not a number' or is infinite,

IsInfinite ( )

IMPORT_C TBoolIsInfinite()const

Determines whether the extended precision value has a finite value.

Return Value
True, if the extended precision value is finite, false, if the value is 'not a number' or is infinite,

IsNaN ( )

IMPORT_C TBoolIsNaN()const

Determines whether the extended precision value is 'not a number'.

Return Value
True, if the extended precision value is 'not a number', false, otherwise.

IsZero ( )

IMPORT_C TBoolIsZero()const

Determines whether the extended precision value is zero.

Return Value
True, if the extended precision value is zero, false, otherwise.

Mod ( TRealX &, const TRealX & )

IMPORT_C TIntMod(TRealX &aResult,
const TRealX &aVal
)const

Modulo-divides this extended precision number by an extended precision value.

Parameters
aResultOn return, a reference to an extended precision object containing the result of the operation.
aValThe extended precision value to be used as the divisor.
Return Value
KErrNone, if the operation is successful; KErrTotalLossOfPrecision, if precision is lost; KErrUnderflow, if the operation results in underflow.

ModEq ( const TRealX & )

IMPORT_C TIntModEq(const TRealX &aVal)

Modulo-divides this extended precision number by an extended precision value.

Parameters
aValThe extended precision value to be used as the divisor.
Return Value
KErrNone, if the operation is successful; KErrTotalLossOfPrecision, if precision is lost; KErrUnderflow, if the operation results in underflow.

Mult ( TRealX &, const TRealX & )

IMPORT_C TIntMult(TRealX &aResult,
const TRealX &aVal
)const

Multiplies this extended precision number by an extended precision value.

Parameters
aResultOn return, a reference to an extended precision object containing the result of the operation.
aValThe extended precision value to be used as the multiplier.
Return Value
KErrNone, if the operation is successful; KErrOverflow, if the operation results in overflow; KErrUnderflow, if the operation results in underflow.

MultEq ( const TRealX & )

IMPORT_C TIntMultEq(const TRealX &aVal)

Multiplies this extended precision number by an extended precision value.

Parameters
aValThe extended precision value to be used as the multiplier.
Return Value
KErrNone, if the operation is successful; KErrOverflow, if the operation results in overflow; KErrUnderflow, if the operation results in underflow

Set ( TInt )

IMPORT_C TIntSet(TIntaInt)

Gives this extended precision object a new value taken from a signed integer.

Return Value
KErrNone, always.

Set ( TUint )

IMPORT_C TIntSet(TUintaInt)

Gives this extended precision object a new value taken from an unsigned integer.

Return Value
KErrNone, always.

Set ( const TInt64 & )

IMPORT_C TIntSet(const TInt64 &aInt)

Gives this extended precision object a new value taken from a 64 bit integer.

Return Value
KErrNone, always.

Set ( TReal32 )

IMPORT_C TIntSet(TReal32aReal)

Gives this extended precision object a new value taken from a single precision floating point number.

Parameters
aRealThe single precision floating point value.
Return Value
KErrNone, if a valid number; KErrOverflow, if the number is infinite; KErrArgument, if not a number.

Set ( TReal64 )

IMPORT_C TIntSet(TReal64aReal)

Gives this extended precision object a new value taken from a double precision floating point number.

Parameters
aRealThe double precision floating point value.
Return Value
KErrNone, if a valid number; KErrOverflow, if the number is infinite; KErrArgument, if not a number.

SetInfinite ( TBool )

IMPORT_C voidSetInfinite(TBoolaNegative)

Sets the value of this extended precision object to infinity.

Parameters
aNegativeETrue, the value is a negative zero; EFalse, the value is a positive zero.

SetNaN ( )

IMPORT_C voidSetNaN()

Sets the value of this extended precision object to 'not a number'.

SetZero ( TBool )

IMPORT_C voidSetZero(TBoolaNegative = EFalse)

Sets the value of this extended precision object to zero.

Parameters
aNegativeETrue, the value is a negative zero; EFalse, the value is a positive zero, this is the default.

Sub ( TRealX &, const TRealX & )

IMPORT_C TIntSub(TRealX &aResult,
const TRealX &aVal
)const

Subtracts an extended precision value from this extended precision number.

Parameters
aResultOn return, a reference to an extended precision object containing the result of the operation.
aValThe extended precision value to be subtracted.
Return Value
KErrNone, if the operation is successful; KErrOverflow, if the operation results in overflow; KErrUnderflow, if the operation results in underflow.

SubEq ( const TRealX & )

IMPORT_C TIntSubEq(const TRealX &aVal)

Subtracts an extended precision value from this extended precision number.

Parameters
aValThe extended precision value to be subtracted.
Return Value
KErrNone, if the operation is successful; KErrOverflow, if the operation results in overflow; KErrUnderflow, if the operation results in underflow.

operator TInt ( )

IMPORT_Coperator TInt()const

Gets the extended precision value as a signed integer value.

The operator returns:

1. zero , if the extended precision value is not a number

2. 0x7FFFFFFF, if the value is positive and too big to fit into a TInt.

3. 0x80000000, if the value is negative and too big to fit into a TInt.

operator TInt64 ( )

IMPORT_Coperator TInt64()const

Returns the extended precision value as a 64 bit integer value.

The operator returns:

1. zero, if the extended precision value is not a number

2. 0x7FFFFFFF FFFFFFFF, if the value is positive and too big to fit into a TInt64

3. 0x80000000 00000000, if the value is negative and too big to fit into a TInt.

operator TReal32 ( )

IMPORT_Coperator TReal32()const

Returns the extended precision value as a single precision floating point value.

operator TReal64 ( )

IMPORT_Coperator TReal64()const

Returns the extended precision value as a double precision floating point value.

operator TUint ( )

IMPORT_Coperator TUint()const

Returns the extended precision value as an unsigned signed integer value.

The operator returns:

1. zero, if the extended precision value is not a number

2. 0xFFFFFFFF, if the value is positive and too big to fit into a TUint.

3. zero, if the value is negative and too big to fit into a TUint.

operator!= ( const TRealX & )

TBool operator!=(const TRealX &aVal)const [inline]

Compares this extended precision number for in-equality with another.

Parameters
aValA reference to the extended precision value to be compared.
Return Value
True, if this extended precision number is not equal to aVal; false, otherwise.

operator% ( const TRealX & )

IMPORT_C TRealXoperator%(const TRealX &aVal)const

Modulo-divides this extended precision number by an extended precision value.

Parameters
aValThe extended precision value to be used as the divisor.
Return Value
An extended precision object containing the result.
Panic Codes
MATHXKErrTotalLossOfPrecision if precision is lost.
MATHXKErrUnderflow if the operation results in underflow.

operator%= ( const TRealX & )

IMPORT_C const TRealX &operator%=(const TRealX &aVal)

Modulo-divides this extended precision number by an extended precision value.

Parameters
aValThe extended precision value to be used as the divisor.
Return Value
A reference to this object.
Panic Codes
MATHXKErrTotalLossOfPrecision panic if precision is lost.
MATHXKErrUnderflow if the operation results in underflow.

operator* ( const TRealX & )

IMPORT_C TRealXoperator*(const TRealX &aVal)const

Multiplies this extended precision number by an extended precision value.

Parameters
aValThe extended precision value to be used as the multiplier.
Return Value
An extended precision object containing the result.
Panic Codes
MATHXKErrOverflow if the operation results in overflow.
MATHXKErrUnderflow if the operation results in underflow.

operator*= ( const TRealX & )

IMPORT_C const TRealX &operator*=(const TRealX &aVal)

Multiplies this extended precision number by an extended precision value.

Parameters
aValThe extended precision value to be subtracted.
Return Value
A reference to this object.
Panic Codes
MATHXKErrOverflow if the operation results in overflow.
MATHXKErrUnderflow if the operation results in underflow.

operator+ ( )

IMPORT_C TRealXoperator+()const

Returns this extended precision number unchanged.

Note that this may also be referred to as a unary plus operator.

Return Value
The extended precision number.

operator+ ( const TRealX & )

IMPORT_C TRealXoperator+(const TRealX &aVal)const

Adds an extended precision value to this extended precision number.

Parameters
aValThe extended precision value to be added.
Return Value
An extended precision object containing the result.
Panic Codes
MATHXKErrOverflow if the operation results in overflow.
MATHXKErrUnderflow if the operation results in underflow.

operator++ ( )

IMPORT_C TRealX &operator++()

Increments this extended precision number by one, and then returns a reference to it.

This is also referred to as a prefix operator.

Return Value
A reference to this object.
Panic Codes
MATHXKErrOverflow if the operation results in overflow.
MATHXKErrUnderflow if the operation results in underflow.

operator++ ( TInt )

IMPORT_C TRealXoperator++(TInt)

Returns this extended precision number before incrementing it by one.

This is also referred to as a postfix operator.

Return Value
A reference to this object.
Panic Codes
MATHXKErrOverflow if the operation results in overflow.
MATHXKErrUnderflow if the operation results in underflow.

operator+= ( const TRealX & )

IMPORT_C const TRealX &operator+=(const TRealX &aVal)

Adds an extended precision value to this extended precision number.

Parameters
aValThe extended precision value to be added.
Return Value
A reference to this object.
Panic Codes
MATHXKErrOverflow if the operation results in overflow.
MATHXKErrUnderflow if the operation results in underflow.

operator- ( )

IMPORT_C TRealXoperator-()const

Negates this extended precision number.

This may also be referred to as a unary minus operator.

Return Value
The negative of the extended precision number.

operator- ( const TRealX & )

IMPORT_C TRealXoperator-(const TRealX &aVal)const

Subtracts an extended precision value from this extended precision number.

Parameters
aValThe extended precision value to be subtracted.
Return Value
An extended precision object containing the result.
Panic Codes
MATHXKErrOverflow if the operation results in overflow.
MATHXKErrUnderflow if the operation results in underflow.

operator-- ( )

IMPORT_C TRealX &operator--()

Decrements this extended precision number by one, and then returns a reference to it.

This is also referred to as a prefix operator.

Return Value
A reference to this object.
Panic Codes
MATHXKErrOverflow if the operation results in overflow.
MATHXKErrUnderflow if the operation results in underflow.

operator-- ( TInt )

IMPORT_C TRealXoperator--(TInt)

Returns this extended precision number before decrementing it by one.

This is also referred to as a postfix operator.

Return Value
A reference to this object.
Panic Codes
MATHXKErrOverflow if the operation results in overflow.
MATHXKErrUnderflow if the operation results in underflow.

operator-= ( const TRealX & )

IMPORT_C const TRealX &operator-=(const TRealX &aVal)

Subtracts an extended precision value from this extended precision number.

Parameters
aValThe extended precision value to be subtracted.
Return Value
A reference to this object.
Panic Codes
MATHXKErrOverflow if the operation results in overflow.
MATHXKErrUnderflow if the operation results in underflow.

operator/ ( const TRealX & )

IMPORT_C TRealXoperator/(const TRealX &aVal)const

Divides this extended precision number by an extended precision value.

Parameters
aValThe extended precision value to be used as the divisor.
Return Value
An extended precision object containing the result.
Panic Codes
MATHXKErrOverflow if the operation results in overflow.
MATHXKErrUnderflow if the operation results in underflow.
MATHXKErrDivideByZero if the divisor is zero.

operator/= ( const TRealX & )

IMPORT_C const TRealX &operator/=(const TRealX &aVal)

Divides this extended precision number by an extended precision value.

Parameters
aValThe extended precision value to be used as the divisor.
Return Value
A reference to this object.
Panic Codes
MATHXKErrOverflow if the operation results in overflow.
MATHXKErrUnderflow if the operation results in underflow.
MATHXKErrDivideByZero if the divisor is zero.

operator< ( const TRealX & )

TBool operator<(const TRealX &aVal)const [inline]

Compares this extended precision number for being less than another.

Parameters
aValA reference to the extended precision value to be compared.
Return Value
True, if this extended precision number is less than aVal, false, otherwise.

operator<= ( const TRealX & )

TBool operator<=(const TRealX &aVal)const [inline]

Compares this extended precision number for being less than or equal to another.

Parameters
aValA reference to the extended precision value to be compared.
Return Value
True, if this extended precision number is less than or equal to aVal, false, otherwise.

operator= ( TInt )

IMPORT_C TRealX &operator=(TIntaInt)

Assigns the specified signed integer value to this extended precision object.

Return Value
A reference to this extended precision object.

operator= ( TUint )

IMPORT_C TRealX &operator=(TUintaInt)

Assigns the specified unsigned integer value to this extended precision object.

Return Value
A reference to this extended precision object.

operator= ( const TInt64 & )

IMPORT_C TRealX &operator=(const TInt64 &aInt)

Assigns the specified 64 bit integer value to this extended precision object.

Return Value
A reference to this extended precision object.

operator= ( TReal32 )

IMPORT_C TRealX &operator=(TReal32aReal)

Assigns the specified single precision floating point number to this extended precision object.

Parameters
aRealThe single precision floating point value.
Return Value
A reference to this extended precision object.

operator= ( TReal64 )

IMPORT_C TRealX &operator=(TReal64aReal)

Assigns the specified double precision floating point number to this extended precision object.

Parameters
aRealThe double precision floating point value.
Return Value
A reference to this extended precision object.

operator== ( const TRealX & )

TBool operator==(const TRealX &aVal)const [inline]

Compares this extended precision number for equality with another.

Parameters
aValA reference to the extended precision value to be compared.
Return Value
True, if this extended precision number is equal to aVal; false, otherwise.

operator> ( const TRealX & )

TBool operator>(const TRealX &aVal)const [inline]

Compares this extended precision number for being greater than another.

Parameters
aValA reference to the extended precision value to be compared.
Return Value
True, if this extended precision number is greater than aVal, false, otherwise.

operator>= ( const TRealX & )

TBool operator>=(const TRealX &aVal)const [inline]

Compares this extended precision number for being greater than or equal to another.

Parameters
aValA reference to the extended precision value to be compared.
Return Value
True, if this extended precision number is greater than or equal to aVal, false, otherwise.