#include <e32math.h>
Link against:
euser.lib
class Math;
Description
A collection of mathematical functions.
Members
Defined in Math
:
ACos(TReal &,const TReal &)
Calculates the principal value of the inverse cosine of a number.
ASin(TReal &,const TReal &)
Calculates the principal value of the inverse sine of a number.
ATan(TReal &,const TReal &)
Calculates the principal value of the inverse tangent of a number.
ATan(TReal &,const TReal &,const TReal &)
Calculates the angle between the x-axis and a line drawn from the origin to a po...
Cos(TReal &,const TReal &)
Calculates the cosine of a number.
DivMod64(Int64,Int64,Int64 &)
Divides aDividend by aDivisor.
DtoR(TReal &,const TDesC &,TInt &,const TChar)
This function is not implemented by Symbian OS.
Exp(TReal &,const TReal &)
Calculates the value of e to the power of x.
FRand(TInt64 &)
Generates a stream of uniformly distributed pseudo-random real numbers in the ra...
Frac(TReal &,const TReal &)
Calculates the fractional part of a number.
Int(TInt16 &,const TReal &)
Calculates the integer part of a number.
Int(TInt32 &,const TReal &)
Calculates the integer part of a number.
Int(TReal &,const TReal &)
Calculates the integer part of a number.
IsFinite(const TReal &)
Determines whether a value is finite.
IsInfinite(const TReal &)
Determines whether a value is infinite.
IsNaN(const TReal &)
Determines whether a value is not a number.
IsZero(const TReal &)
Determines whether a value is zero.
Ln(TReal &,const TReal &)
Calculates the natural logarithm of a number.
Log(TReal &,const TReal &)
Calculates the logarithm to base 10 of a number.
Mod(TReal &,const TReal &,const TReal &)
Calculates the modulo remainder.
Mul64(Int64,Int64,Int64 &,Uint64 &)
Multiply aX by aY to generate a 128 bit result.
Poly(TReal,const SPoly *)
Evaluates the polynomial: {a[n]X^n + a[n-1]X^(n-1) + ... + a[2]X^2 + a[1]X^1 + a...
PolyX(TRealX &,const TRealX &,TInt,const TRealX *)
Evaluates the polynomial: {a[n]X^n + a[n-1]X^(n-1) + ... + a[2]X^2 + a[1]X^1 + a...
Pow(TReal &,const TReal &,const TReal &)
Calculates the value of x raised to the power of y.
Pow10(TReal &,const TInt)
Calculates the value of 10 to the power of x.
Rand(TInt64 &)
Generates a stream of uniformly distributed pseudo-random integers in the range,...
Random()
Gets 32 random bits from the kernel's random pool.
Round(TReal &,const TReal &,TInt)
Rounds to a specified number of decimal places.
Sin(TReal &,const TReal &)
Calculates the sine of a number.
Sqrt(TReal &,const TReal &)
Calculates the square root of a number.
Tan(TReal &,const TReal &)
Calculates the tangent of a number.
UDivMod64(Uint64,Uint64,Uint64 &)
Divides aDividend by aDivisor.
UMul64(Uint64,Uint64,Uint64 &,Uint64 &)
Multiply aX by aY to generate a 128 bit result.
Member functions
ACos(TReal &,const TReal &)
IMPORT_C static TInt ACos(TReal &aTrg, const TReal &aSrc);
Description
Calculates the principal value of the inverse cosine of a number.
Parameters
TReal &aTrg |
A reference containing the result in radians, a value between 0 and pi.
|
const TReal &aSrc |
The argument of the arccos function, a value between -1 and +1 inclusive.
|
|
Return value
TInt
|
KErrNone if successful, otherwise another of the system-wide error codes.
|
|
ASin(TReal &,const TReal &)
IMPORT_C static TInt ASin(TReal &aTrg, const TReal &aSrc);
Description
Calculates the principal value of the inverse sine of a number.
Parameters
TReal &aTrg |
A reference containing the result in radians, a value between -pi/2 and +pi/2.
|
const TReal &aSrc |
The argument of the arcsin function, a value between -1 and +1 inclusive.
|
|
Return value
TInt
|
KErrNone if successful, otherwise another of the system-wide error codes.
|
|
ATan(TReal &,const TReal &)
IMPORT_C static TInt ATan(TReal &aTrg, const TReal &aSrc);
Description
Calculates the principal value of the inverse tangent of a number.
Parameters
TReal &aTrg |
A reference containing the result in radians, a value between -pi/2 and +pi/2.
|
const TReal &aSrc |
The argument of the arctan function, a value between +infinity and +infinity.
|
|
Return value
TInt
|
KErrNone if successful, otherwise another of the system-wide error codes.
|
|
ATan(TReal &,const TReal &,const TReal &)
IMPORT_C static TInt ATan(TReal &aTrg, const TReal &aSrcY, const TReal &aSrcX);
Description
Calculates the angle between the x-axis and a line drawn from the origin to a point represented by its (x,y) co-ordinates.
The co-ordinates are passed as arguments to the function. This function returns the same result as arctan(y/x), but:
1. it adds +/-pi to the result, if x is negative
2. it sets the result to +/-pi/2, if x is zero but y is non-zero.
Parameters
TReal &aTrg |
A reference containing the result in radians, a value between -pi exclusive and +pi inclusive.
|
const TReal &aSrcY |
The y argument of the arctan(y/x) function.
|
const TReal &aSrcX |
The x argument of the arctan(y/x) function.
|
|
Return value
TInt
|
KErrNone if successful, otherwise another of the system-wide error codes.
|
|
Cos(TReal &,const TReal &)
IMPORT_C static TInt Cos(TReal &aTrg, const TReal &aSrc);
Description
Calculates the cosine of a number.
Parameters
TReal &aTrg |
A reference containing the result.
|
const TReal &aSrc |
The argument of the cos function in radians
|
|
Return value
TInt
|
KErrNone if successful, otherwise another of the system-wide error codes.
|
|
DtoR(TReal &,const TDesC &,TInt &,const TChar)
IMPORT_C static TInt DtoR(TReal &aTrg, const TDesC &aSrc, TInt &aPos, const TChar aPoint);
Description
This function is not implemented by Symbian OS.
Parameters
Return value
Exp(TReal &,const TReal &)
IMPORT_C static TInt Exp(TReal &aTrg, const TReal &aSrc);
Description
Calculates the value of e to the power of x.
Parameters
TReal &aTrg |
A reference containing the result.
|
const TReal &aSrc |
The power to which e is to be raised.
|
|
Return value
TInt
|
KErrNone if successful, otherwise another of the system-wide error codes.
|
|
Frac(TReal &,const TReal &)
IMPORT_C static TInt Frac(TReal &aTrg, const TReal &aSrc);
Description
Calculates the fractional part of a number.
The fractional part is that after a decimal point. Truncation is toward zero, so that Frac(2.4)=0.4, Frac(2)=0, Frac(-1)=0,
Frac(-1.4)=0.4.
Parameters
TReal &aTrg |
A reference containing the result.
|
const TReal &aSrc |
The number whose fractional part is required.
|
|
Return value
TInt
|
KErrNone if successful, otherwise another of the system-wide error codes.
|
|
Int(TReal &,const TReal &)
IMPORT_C static TInt Int(TReal &aTrg, const TReal &aSrc);
Description
Calculates the integer part of a number.
The integer part is that before a decimal point. Truncation is toward zero, so that int(2.4)=2, int(2)=2, int(-1)=-1, int(-1.4)=-1,
int(-1.999)=-1.
Parameters
TReal &aTrg |
A reference containing the result.
|
const TReal &aSrc |
The number whose integer part is required.
|
|
Return value
TInt
|
KErrNone if successful, otherwise another of the system-wide error codes.
|
|
Int(TInt16 &,const TReal &)
IMPORT_C static TInt Int(TInt16 &aTrg, const TReal &aSrc);
Description
Calculates the integer part of a number.
The integer part is that before a decimal point. Truncation is toward zero, so that int(2.4)=2, int(2)=2, int(-1)=-1, int(-1.4)=-1,
int(-1.999)=-1.
This function is suitable when the result is known to be small enough for a 16-bit signed integer.
Parameters
TInt16 &aTrg |
A reference containing the result.
|
const TReal &aSrc |
The number whose integer part is required.
|
|
Return value
TInt
|
KErrNone if successful, otherwise another of the system-wide error codes.
|
|
Int(TInt32 &,const TReal &)
IMPORT_C static TInt Int(TInt32 &aTrg, const TReal &aSrc);
Description
Calculates the integer part of a number.
The integer part is that before a decimal point. Truncation is toward zero, so that int(2.4)=2, int(2)=2, int(-1)=-1, int(-1.4)=-1,
int(-1.999)=-1.
This function is suitable when the result is known to be small enough for a 32-bit signed integer.
Parameters
TInt32 &aTrg |
A reference containing the result.
|
const TReal &aSrc |
The number whose integer part is required.
|
|
Return value
TInt
|
KErrNone if successful, otherwise another of the system-wide error codes.
|
|
Log(TReal &,const TReal &)
IMPORT_C static TInt Log(TReal &aTrg, const TReal &aSrc);
Description
Calculates the logarithm to base 10 of a number.
Parameters
TReal &aTrg |
A reference containing the result.
|
const TReal &aSrc |
The number whose logarithm is required.
|
|
Return value
TInt
|
KErrNone if successful, otherwise another of the system-wide error codes.
|
|
Ln(TReal &,const TReal &)
IMPORT_C static TInt Ln(TReal &aTrg, const TReal &aSrc);
Description
Calculates the natural logarithm of a number.
Parameters
TReal &aTrg |
A reference containing the result.
|
const TReal &aSrc |
The number whose natural logarithm is required.
|
|
Return value
TInt
|
KErrNone if successful, otherwise another of the system-wide error codes.
|
|
Mod(TReal &,const TReal &,const TReal &)
IMPORT_C static TInt Mod(TReal &aTrg, const TReal &aSrc, const TReal &aModulus);
Description
Calculates the modulo remainder.
This is the value of p mod q, the modulo remainder when dividing p by q. The result is given by p - q int (p/q): it has the
same sign as p: thus, 5 mod 3 = 2, -5 mod 3 = -2. No error is raised if non-integer arguments are passed.
Parameters
TReal &aTrg |
A reference containing the result.
|
const TReal &aSrc |
The p argument to the mod function.
|
const TReal &aModulus |
The q argument to the mod function.
|
|
Return value
TInt
|
KErrNone if successful, otherwise another of the system-wide error codes.
|
|
Poly(TReal,const SPoly *)
IMPORT_C static TReal Poly(TReal aVal, const SPoly *aPoly);
Description
Evaluates the polynomial: {a[n]X^n + a[n-1]X^(n-1) + ... + a[2]X^2 + a[1]X^1 + a[0]}.
Parameters
TReal aVal |
The value of the x-variable
|
const SPoly *aPoly |
A pointer to the structure containing the set of coefficients in the order: a[0], a[1], ..., a[n-1], a[n].
|
|
Return value
TReal
|
The result of the evaluation.
|
|
Pow(TReal &,const TReal &,const TReal &)
IMPORT_C static TInt Pow(TReal &aTrg, const TReal &aSrc, const TReal &aPower);
Description
Calculates the value of x raised to the power of y.
The behaviour conforms to that specified for pow() in the ISO C Standard ISO/IEC 9899 (Annex F), although floating-point exceptions
are not supported.
Parameters
TReal &aTrg |
A reference containing the result.
|
const TReal &aSrc |
The x argument of the function.
|
const TReal &aPower |
The y argument of the function.
|
|
Return value
TInt
|
KErrNone if successful; KErrOverflow if the result is +/- infinity; KErrUnderflow if the result is too small to be represented;
KErrArgument if the result is not a number (NaN).
|
|
Pow10(TReal &,const TInt)
IMPORT_C static TInt Pow10(TReal &aTrg, const TInt exp);
Description
Calculates the value of 10 to the power of x.
Parameters
TReal &aTrg |
A reference containing the result.
|
const TInt exp |
The power to which 10 is to be raised.
|
|
Return value
TInt
|
KErrNone if successful, otherwise another of the system-wide error codes.
|
|
IMPORT_C static TInt Rand(TInt64 &aSeed);
Description
Generates a stream of uniformly distributed pseudo-random integers in the range, 0 to KMaxTInt.
For each stream of pseudo-random numbers you wish to generate, you should pass the reference to the same 64-bit seed on each
call to this function. You should not change the seed between calls.
Parameters
TInt64 &aSeed |
A reference to a 64-bit seed, which is updated as a result of the call.
|
|
Return value
TInt
|
The next pseudo-random number in the sequence.
|
|
IMPORT_C static TReal FRand(TInt64 &aSeed);
Description
Generates a stream of uniformly distributed pseudo-random real numbers in the range, 0 to 1.
Parameters
TInt64 &aSeed |
A reference to a 64-bit seed, which is updated as a result of the call.
|
|
Return value
TReal
|
The next pseudo-random number in the sequence.
|
|
IMPORT_C static TUint32 Random();
Description
Gets 32 random bits from the kernel's random pool.
Return value
Round(TReal &,const TReal &,TInt)
IMPORT_C static TInt Round(TReal &aTrg, const TReal &aSrc, TInt aDecimalPlaces);
Description
Rounds to a specified number of decimal places.
The function rounds a number to a given number, n, of decimal places. Rounding may be thought of as multiplying the number
by 10 to the power of n, rounding to the nearest integer, and then dividing the result by 10 to the power of n and returning
that as the answer.
In the process of rounding, numbers ending with .5 are rounded away from zero, so that 1.5 becomes 2, 2.5 becomes 3, -1.5
becomes -2, etc.
Parameters
TReal &aTrg |
A reference containing the result.
|
const TReal &aSrc |
The number to be rounded.
|
TInt aDecimalPlaces |
The number of decimal places to round to: must be zero or positive.
|
|
Return value
TInt
|
KErrNone if successful, otherwise another of the system-wide error codes.
|
|
Sin(TReal &,const TReal &)
IMPORT_C static TInt Sin(TReal &aTrg, const TReal &aSrc);
Description
Calculates the sine of a number.
Parameters
TReal &aTrg |
A reference containing the result.
|
const TReal &aSrc |
The argument of the sin function in radians.
|
|
Return value
TInt
|
KErrNone if successful, otherwise another of the system-wide error codes.
|
|
Sqrt(TReal &,const TReal &)
IMPORT_C static TInt Sqrt(TReal &aTrg, const TReal &aSrc);
Description
Calculates the square root of a number.
Parameters
TReal &aTrg |
A reference containing the result.
|
const TReal &aSrc |
The number whose square-root is required.
|
|
Return value
TInt
|
KErrNone if successful, otherwise another of the system-wide error codes.
|
|
Tan(TReal &,const TReal &)
IMPORT_C static TInt Tan(TReal &aTrg, const TReal &aSrc);
Description
Calculates the tangent of a number.
Parameters
TReal &aTrg |
A reference containing the result.
|
const TReal &aSrc |
The argument of the tan function in radians.
|
|
Return value
TInt
|
KErrNone if successful, otherwise another of the system-wide error codes.
|
|
IMPORT_C static TBool IsZero(const TReal &aVal);
Description
Determines whether a value is zero.
Parameters
const TReal &aVal |
A reference to the value to be checked.
|
|
Return value
TBool
|
True, if aVal is zero; false, otherwise.
|
|
IMPORT_C static TBool IsNaN(const TReal &aVal);
Description
Determines whether a value is not a number.
Parameters
const TReal &aVal |
A reference to the value to be checked.
|
|
Return value
TBool
|
True, if aVal is not a number; false, otherwise.
|
|
IsInfinite(const TReal &)
IMPORT_C static TBool IsInfinite(const TReal &aVal);
Description
Determines whether a value is infinite.
Parameters
const TReal &aVal |
A reference to the value to be checked.
|
|
Return value
TBool
|
True, if aVal is infinite; false, otherwise.
|
|
IMPORT_C static TBool IsFinite(const TReal &aVal);
Description
Determines whether a value is finite.
In this context, a value is finite if it is a valid number and is not infinite.
Parameters
const TReal &aVal |
A reference to the value to be checked.
|
|
Return value
TBool
|
True, if aVal is finite; false, otherwise.
|
|
PolyX(TRealX &,const TRealX &,TInt,const TRealX *)
IMPORT_C static void PolyX(TRealX &aY, const TRealX &aX, TInt aDeg, const TRealX *aCoef);
Description
Evaluates the polynomial: {a[n]X^n + a[n-1]X^(n-1) + ... + a[2]X^2 + a[1]X^1 + a[0]}.
Parameters
TRealX &aY |
A reference containing the result.
|
const TRealX &aX |
The value of the x-variable.
|
TInt aDeg |
The degree of the polynomial (the highest power of x which is present).
|
const TRealX *aCoef |
A pointer to a contiguous set of TRealX values containing the coefficients. They must be in the order: a[0], a[1], ..., a[n-1], a[n].
|
|
Mul64(Int64,Int64,Int64 &,Uint64 &)
IMPORT_C static void Mul64(Int64 aX, Int64 aY, Int64 &aOutH, Uint64 &aOutL);
Description
Multiply aX by aY to generate a 128 bit result.
The high order 64 bits of this calculation are stored in aOutH, and the low order 64 bits are stored in aOutL.
Parameters
Int64 aX |
The first 64-bit operand.
|
Int64 aY |
The second 64-bit operand.
|
Int64 &aOutH |
The high order 64 bits of the result.
|
Uint64 &aOutL |
The low order 64 bits of the result.
|
|
UMul64(Uint64,Uint64,Uint64 &,Uint64 &)
IMPORT_C static void UMul64(Uint64 aX, Uint64 aY, Uint64 &aOutH, Uint64 &aOutL);
Description
Multiply aX by aY to generate a 128 bit result.
The high order 64 bits of this calculation are stored in aOutH, and the low order 64 bits are stored in aOutL.
Parameters
Uint64 aX |
The first 64-bit operand.
|
Uint64 aY |
The second 64-bit operand.
|
Uint64 &aOutH |
The high order 64 bits of the result.
|
Uint64 &aOutL |
The low order 64 bits of the result.
|
|
DivMod64(Int64,Int64,Int64 &)
IMPORT_C static Int64 DivMod64(Int64 aDividend, Int64 aDivisor, Int64 &aRemainder);
Description
Divides aDividend by aDivisor.
The quotient is returned, and the remainder is stored in aRemainder. The remainder has same sign as the dividend.
Parameters
Int64 aDividend |
The 64-bit dividend.
|
Int64 aDivisor |
The 64-bit divisor.
|
Int64 &aRemainder |
The 64-bit remainder.
|
|
Return value
Int64 |
The 64-bit quotient.
|
|
UDivMod64(Uint64,Uint64,Uint64 &)
IMPORT_C static Uint64 UDivMod64(Uint64 aDividend, Uint64 aDivisor, Uint64 &aRemainder);
Description
Divides aDividend by aDivisor.
The quotient is returned, and the remainder is stored in aRemainder.
Parameters
Uint64 aDividend |
The 64-bit dividend.
|
Uint64 aDivisor |
The 64-bit divisor.
|
Uint64 &aRemainder |
The 64-bit remainder.
|
|
Return value
Uint64 |
The 64-bit quotient.
|
|