#include <e32math.h>
class Math |
Public Member Functions | |
---|---|
IMPORT_C TInt | ACos(TReal &, const TReal &) |
IMPORT_C TInt | ASin(TReal &, const TReal &) |
IMPORT_C TInt | ATan(TReal &, const TReal &) |
IMPORT_C TInt | ATan(TReal &, const TReal &, const TReal &) |
IMPORT_C TInt | Cos(TReal &, const TReal &) |
IMPORT_C Int64 | DivMod64(Int64, Int64, Int64 &) |
IMPORT_C TInt | Exp(TReal &, const TReal &) |
IMPORT_C TReal | FRand(TInt64 &) |
IMPORT_C TInt | Frac(TReal &, const TReal &) |
IMPORT_C TInt | Int(TReal &, const TReal &) |
IMPORT_C TInt | Int(TInt16 &, const TReal &) |
IMPORT_C TInt | Int(TInt32 &, const TReal &) |
IMPORT_C TBool | IsFinite(const TReal &) |
IMPORT_C TBool | IsInfinite(const TReal &) |
IMPORT_C TBool | IsNaN(const TReal &) |
IMPORT_C TBool | IsZero(const TReal &) |
IMPORT_C TInt | Ln(TReal &, const TReal &) |
IMPORT_C TInt | Log(TReal &, const TReal &) |
IMPORT_C TInt | Mod(TReal &, const TReal &, const TReal &) |
IMPORT_C void | Mul64(Int64, Int64, Int64 &, Uint64 &) |
TInt | MultPow10X(TRealX &, TInt) |
IMPORT_C TReal | Poly(TReal, const SPoly *) |
IMPORT_C void | PolyX(TRealX &, const TRealX &, TInt, const TRealX *) |
IMPORT_C TInt | Pow(TReal &, const TReal &, const TReal &) |
IMPORT_C TInt | Pow10(TReal &, const TInt) |
IMPORT_C TInt | Rand(TInt64 &) |
IMPORT_C TUint32 | Random() |
IMPORT_C void | Random(TDes8 &) |
IMPORT_C void | RandomL(TDes8 &) |
IMPORT_C TUint32 | RandomL() |
IMPORT_C TInt | Round(TReal &, const TReal &, TInt) |
IMPORT_C TInt | Sin(TReal &, const TReal &) |
IMPORT_C TInt | Sqrt(TReal &, const TReal &) |
IMPORT_C TInt | Tan(TReal &, const TReal &) |
IMPORT_C Uint64 | UDivMod64(Uint64, Uint64, Uint64 &) |
IMPORT_C void | UMul64(Uint64, Uint64, Uint64 &, Uint64 &) |
A collection of mathematical functions.
Calculates the principal value of the inverse cosine of a number.
Parameter | Description |
---|---|
aTrg | A reference containing the result in radians, a value between 0 and pi. |
aSrc | The argument of the arccos function, a value between -1 and +1 inclusive. |
Returns: KErrNone if successful, otherwise another of the system-wide error codes.
Calculates the principal value of the inverse sine of a number.
Parameter | Description |
---|---|
aTrg | A reference containing the result in radians, a value between -pi/2 and +pi/2. |
aSrc | The argument of the arcsin function, a value between -1 and +1 inclusive. |
Returns: KErrNone if successful, otherwise another of the system-wide error codes.
Calculates the principal value of the inverse tangent of a number.
Parameter | Description |
---|---|
aTrg | A reference containing the result in radians, a value between -pi/2 and +pi/2. |
aSrc | The argument of the arctan function, a value between +infinity and +infinity. |
Returns: KErrNone if successful, otherwise another of the system-wide error codes.
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.
Parameter | Description |
---|---|
aTrg | A reference containing the result in radians, a value between -pi exclusive and +pi inclusive. |
aSrcY | The y argument of the arctan(y/x) function. |
aSrcX | The x argument of the arctan(y/x) function. |
Returns: KErrNone if successful, otherwise another of the system-wide error codes.
Divides aDividend by aDivisor.
The quotient is returned, and the remainder is stored in aRemainder. The remainder has same sign as the dividend.
Parameter | Description |
---|---|
aDividend | The 64-bit dividend. |
aDivisor | The 64-bit divisor. |
aRemainder | The 64-bit remainder. |
Returns: The 64-bit quotient.
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.
Parameter | Description |
---|---|
aTrg | A reference containing the result. |
aSrc | The number whose fractional part is required. |
Returns: KErrNone if successful, otherwise another of the system-wide error codes.
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.
Parameter | Description |
---|---|
aTrg | A reference containing the result. |
aSrc | The number whose integer part is required. |
Returns: KErrNone if successful, otherwise another of the system-wide error codes.
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.
Parameter | Description |
---|---|
aTrg | A reference containing the result. |
aSrc | The number whose integer part is required. |
Returns: KErrNone if successful, otherwise another of the system-wide error codes.
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.
Parameter | Description |
---|---|
aTrg | A reference containing the result. |
aSrc | The number whose integer part is required. |
Returns: KErrNone if successful, otherwise another of the system-wide error codes.
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.
Parameter | Description |
---|---|
aTrg | A reference containing the result. |
aSrc | The p argument to the mod function. |
aModulus | The q argument to the mod function. |
Returns: KErrNone if successful, otherwise another of the system-wide error codes.
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.
Parameter | Description |
---|---|
aX | The first 64-bit operand. |
aY | The second 64-bit operand. |
aOutH | The high order 64 bits of the result. |
aOutL | The low order 64 bits of the result. |
Evaluates the polynomial: {a[n]X^n + a[n-1]X^(n-1) + ... + a[2]X^2 + a[1]X^1 + a[0]}.
Parameter | Description |
---|---|
aVal | The value of the x-variable |
aPoly | A pointer to the structure containing the set of coefficients in the order: a[0], a[1], ..., a[n-1], a[n]. |
Returns: The result of the evaluation.
Evaluates the polynomial: {a[n]X^n + a[n-1]X^(n-1) + ... + a[2]X^2 + a[1]X^1 + a[0]}.
Parameter | Description |
---|---|
aY | A reference containing the result. |
aX | The value of the x-variable. |
aDeg | The degree of the polynomial (the highest power of x which is present). |
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]. |
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.
Parameter | Description |
---|---|
aTrg | A reference containing the result. |
aSrc | The x argument of the function. |
aPower | The y argument of the function. |
Returns: 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).
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.
Parameter | Description |
---|---|
aSeed | A reference to a 64-bit seed, which is updated as a result of the call. |
Returns: The next pseudo-random number in the sequence.
IMPORT_C TUint32 | Random | ( | ) | [static] |
Gets 32 random bits from the kernel's random number generator.
The returned random data may or may not be cryptographically secure but should be of a high quality for non-cryptographic purposes.
This function uses a cryptographically strong random number generator to generate the random data, which can be slower than insecure generators. If security is not important, a faster generator may be used such as Math::Rand().
Returns: The 32 random bits.
IMPORT_C void | Random | ( | TDes8 & | aRandomValue | ) | [static] |
Fills the provided descriptor with random data up to its current length. The number of random bytes required should be specified by setting the length of the descriptor that is passed to this function.
The returned random data may or may not be cryptographically secure but should be of a high quality for non-cryptographic purposes.
This function uses a cryptographically strong random number generator to generate the random data, which can be slower than insecure generators. If security is not important, a faster generator may be used such as Math::Rand().
Parameter | Description |
---|---|
aRandomValue | on return, the descriptor is filled with the requested number of random bytes. |
IMPORT_C void | RandomL | ( | TDes8 & | aRandomValue | ) | [static] |
Fills the provided descriptor with random data up to its current length. The number of random bytes required should be specified by setting the length of the descriptor that is passed to the function.
If the returned random data cannot be guaranteed to be cryptographically secure, the function will leave with KErrNotReady to indicate that the returned data should not be used for cryptographic purposes.
The security strength of the cryptographically strong random number generator is 256 bits.
Parameter | Description |
---|---|
aRandomValue | on return, the descriptor is filled with the requested number of random bytes. |
IMPORT_C TUint32 | RandomL | ( | ) | [static] |
Gets 32 random bits from the kernel's random number generator.
If the returned random data could not be guaranteed to be cryptographically secure, the function will instead leave with KErrNotReady to indicate that data was not available.
The security strength of the cryptographically strong random number generator is 256 bits.
Returns: The 32 random bits.
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.
Parameter | Description |
---|---|
aTrg | A reference containing the result. |
aSrc | The number to be rounded. |
aDecimalPlaces | The number of decimal places to round to: must be zero or positive. |
Returns: KErrNone if successful, otherwise another of the system-wide error codes.
Divides aDividend by aDivisor.
The quotient is returned, and the remainder is stored in aRemainder.
Parameter | Description |
---|---|
aDividend | The 64-bit dividend. |
aDivisor | The 64-bit divisor. |
aRemainder | The 64-bit remainder. |
Returns: The 64-bit quotient.
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.
Parameter | Description |
---|---|
aX | The first 64-bit operand. |
aY | The second 64-bit operand. |
aOutH | The high order 64 bits of the result. |
aOutL | The low order 64 bits of the result. |