Original Symbian headers
Selected EUSER, Window Server, networking, graphics and device declarations
Loading...
Searching...
No Matches
Math Class Reference

A collection of mathematical functions. More...

#include <e32math.h>

Static Public Member Functions

static IMPORT_C TInt ACos (TReal &aTrg, const TReal &aSrc)
 Calculates the principal value of the inverse cosine of a number.
 
static IMPORT_C TInt ASin (TReal &aTrg, const TReal &aSrc)
 Calculates the principal value of the inverse sine of a number.
 
static IMPORT_C TInt ATan (TReal &aTrg, const TReal &aSrc)
 Calculates the principal value of the inverse tangent of a number.
 
static IMPORT_C TInt ATan (TReal &aTrg, const TReal &aSrcY, const TReal &aSrcX)
 Calculates the angle between the x-axis and a line drawn from the origin to a point represented by its (x,y) co-ordinates.
 
static IMPORT_C TInt Cos (TReal &aTrg, const TReal &aSrc)
 Calculates the cosine of a number.
 
static IMPORT_C TInt Exp (TReal &aTrg, const TReal &aSrc)
 Calculates the value of e to the power of x.
 
static IMPORT_C TInt Frac (TReal &aTrg, const TReal &aSrc)
 Calculates the fractional part of a number.
 
static IMPORT_C TInt Int (TReal &aTrg, const TReal &aSrc)
 Calculates the integer part of a number.
 
static IMPORT_C TInt Int (TInt16 &aTrg, const TReal &aSrc)
 Calculates the integer part of a number.
 
static IMPORT_C TInt Int (TInt32 &aTrg, const TReal &aSrc)
 Calculates the integer part of a number.
 
static IMPORT_C TInt Log (TReal &aTrg, const TReal &aSrc)
 Calculates the logarithm to base 10 of a number.
 
static IMPORT_C TInt Ln (TReal &aTrg, const TReal &aSrc)
 Calculates the natural logarithm of a number.
 
static IMPORT_C TInt Mod (TReal &aTrg, const TReal &aSrc, const TReal &aModulus)
 Calculates the modulo remainder.
 
static IMPORT_C TReal Poly (TReal aVal, const SPoly *aPoly) __SOFTFP
 Evaluates the polynomial: {a[n]X^n + a[n-1]X^(n-1) + ... + a[2]X^2 + a[1]X^1 + a[0]}.
 
static IMPORT_C TInt Pow (TReal &aTrg, const TReal &aSrc, const TReal &aPower)
 Calculates the value of x raised to the power of y.
 
static IMPORT_C TInt Pow10 (TReal &aTrg, const TInt exp)
 Calculates the value of 10 to the power of x.
 
static IMPORT_C TInt Rand (TInt64 &aSeed)
 Generates a stream of uniformly distributed pseudo-random integers in the range, 0 to KMaxTInt.
 
static IMPORT_C TReal FRand (TInt64 &aSeed) __SOFTFP
 Generates a stream of uniformly distributed pseudo-random real numbers in the range, 0 to 1.
 
static IMPORT_C TUint32 Random ()
 Gets 32 random bits from the kernel's random number generator.
 
static IMPORT_C void Random (TDes8 &aRandomValue)
 Fills the provided descriptor with random data up to its current length.
 
static IMPORT_C void RandomL (TDes8 &aRandomValue)
 Fills the provided descriptor with random data up to its current length.
 
static IMPORT_C TUint32 RandomL ()
 Gets 32 random bits from the kernel's random number generator.
 
static IMPORT_C TInt Round (TReal &aTrg, const TReal &aSrc, TInt aDecimalPlaces)
 Rounds to a specified number of decimal places.
 
static IMPORT_C TInt Sin (TReal &aTrg, const TReal &aSrc)
 Calculates the sine of a number.
 
static IMPORT_C TInt Sqrt (TReal &aTrg, const TReal &aSrc)
 Calculates the square root of a number.
 
static IMPORT_C TInt Tan (TReal &aTrg, const TReal &aSrc)
 Calculates the tangent of a number.
 
static IMPORT_C TBool IsZero (const TReal &aVal)
 Determines whether a value is zero.
 
static IMPORT_C TBool IsNaN (const TReal &aVal)
 Determines whether a value is not a number.
 
static IMPORT_C TBool IsInfinite (const TReal &aVal)
 Determines whether a value is infinite.
 
static IMPORT_C TBool IsFinite (const TReal &aVal)
 Determines whether a value is finite.
 
static IMPORT_C void PolyX (TRealX &aY, const TRealX &aX, TInt aDeg, const TRealX *aCoef)
 Evaluates the polynomial: {a[n]X^n + a[n-1]X^(n-1) + ... + a[2]X^2 + a[1]X^1 + a[0]}.
 
static TInt MultPow10X (TRealX &aTrg, TInt aPower)
 
static IMPORT_C void Mul64 (Int64 aX, Int64 aY, Int64 &aOutH, Uint64 &aOutL)
 Multiply aX by aY to generate a 128 bit result.
 
static IMPORT_C void UMul64 (Uint64 aX, Uint64 aY, Uint64 &aOutH, Uint64 &aOutL)
 Multiply aX by aY to generate a 128 bit result.
 
static IMPORT_C Int64 DivMod64 (Int64 aDividend, Int64 aDivisor, Int64 &aRemainder)
 Divides aDividend by aDivisor.
 
static IMPORT_C Uint64 UDivMod64 (Uint64 aDividend, Uint64 aDivisor, Uint64 &aRemainder)
 Divides aDividend by aDivisor.
 

Detailed Description

A collection of mathematical functions.

API status
Published to all clients. Released API.

Definition at line 519 of file e32math.h.

Member Function Documentation

◆ ACos()

static IMPORT_C TInt Math::ACos ( TReal &  aTrg,
const TReal &  aSrc 
)
static

Calculates the principal value of the inverse cosine of a number.

Parameters
aTrgA reference containing the result in radians, a value between 0 and pi.
aSrcThe argument of the arccos function, a value between -1 and +1 inclusive.

(generated from Symbian Developer Library)

◆ ASin()

static IMPORT_C TInt Math::ASin ( TReal &  aTrg,
const TReal &  aSrc 
)
static

Calculates the principal value of the inverse sine of a number.

Parameters
aTrgA reference containing the result in radians, a value between -pi/2 and +pi/2.
aSrcThe argument of the arcsin function, a value between -1 and +1 inclusive.

(generated from Symbian Developer Library)

◆ ATan() [1/2]

static IMPORT_C TInt Math::ATan ( TReal &  aTrg,
const TReal &  aSrc 
)
static

Calculates the principal value of the inverse tangent of a number.

Parameters
aTrgA reference containing the result in radians, a value between -pi/2 and +pi/2.
aSrcThe argument of the arctan function, a value between +infinity and +infinity.

(generated from Symbian Developer Library)

◆ ATan() [2/2]

static IMPORT_C TInt Math::ATan ( TReal &  aTrg,
const TReal &  aSrcY,
const TReal &  aSrcX 
)
static

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
aTrgA reference containing the result in radians, a value between -pi exclusive and +pi inclusive.
aSrcYThe y argument of the arctan(y/x) function.
aSrcXThe x argument of the arctan(y/x) function.

(generated from Symbian Developer Library)

◆ Cos()

static IMPORT_C TInt Math::Cos ( TReal &  aTrg,
const TReal &  aSrc 
)
static

Calculates the cosine of a number.

Parameters
aTrgA reference containing the result.
aSrcThe argument of the cos function in radians

(generated from Symbian Developer Library)

◆ DivMod64()

static IMPORT_C Int64 Math::DivMod64 ( Int64  aDividend,
Int64  aDivisor,
Int64 &  aRemainder 
)
static

Divides aDividend by aDivisor.

The quotient is returned, and the remainder is stored in aRemainder. The remainder has same sign as the dividend.

Parameters
aDividendThe 64-bit dividend.
aDivisorThe 64-bit divisor.
aRemainderThe 64-bit remainder.

(generated from Symbian Developer Library)

◆ Exp()

static IMPORT_C TInt Math::Exp ( TReal &  aTrg,
const TReal &  aSrc 
)
static

Calculates the value of e to the power of x.

Parameters
aTrgA reference containing the result.
aSrcThe power to which e is to be raised.

(generated from Symbian Developer Library)

◆ Frac()

static IMPORT_C TInt Math::Frac ( TReal &  aTrg,
const TReal &  aSrc 
)
static

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
aTrgA reference containing the result.
aSrcThe number whose fractional part is required.

(generated from Symbian Developer Library)

◆ FRand()

static IMPORT_C TReal Math::FRand ( TInt64 &  aSeed)
static

Generates a stream of uniformly distributed pseudo-random real numbers in the range, 0 to 1.

Parameters
aSeedA reference to a 64-bit seed, which is updated as a result of the call.

(generated from Symbian Developer Library)

◆ Int() [1/3]

static IMPORT_C TInt Math::Int ( TInt16 &  aTrg,
const TReal &  aSrc 
)
static

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
aTrgA reference containing the result.
aSrcThe number whose integer part is required.

(generated from Symbian Developer Library)

◆ Int() [2/3]

static IMPORT_C TInt Math::Int ( TInt32 &  aTrg,
const TReal &  aSrc 
)
static

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
aTrgA reference containing the result.
aSrcThe number whose integer part is required.

(generated from Symbian Developer Library)

◆ Int() [3/3]

static IMPORT_C TInt Math::Int ( TReal &  aTrg,
const TReal &  aSrc 
)
static

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
aTrgA reference containing the result.
aSrcThe number whose integer part is required.

(generated from Symbian Developer Library)

◆ IsFinite()

static IMPORT_C TBool Math::IsFinite ( const TReal &  aVal)
static

Determines whether a value is finite.

In this context, a value is finite if it is a valid number and is not infinite.

Parameters
aValA reference to the value to be checked.

(generated from Symbian Developer Library)

◆ IsInfinite()

static IMPORT_C TBool Math::IsInfinite ( const TReal &  aVal)
static

Determines whether a value is infinite.

Parameters
aValA reference to the value to be checked.

(generated from Symbian Developer Library)

◆ IsNaN()

static IMPORT_C TBool Math::IsNaN ( const TReal &  aVal)
static

Determines whether a value is not a number.

Parameters
aValA reference to the value to be checked.

(generated from Symbian Developer Library)

◆ IsZero()

static IMPORT_C TBool Math::IsZero ( const TReal &  aVal)
static

Determines whether a value is zero.

Parameters
aValA reference to the value to be checked.

(generated from Symbian Developer Library)

◆ Ln()

static IMPORT_C TInt Math::Ln ( TReal &  aTrg,
const TReal &  aSrc 
)
static

Calculates the natural logarithm of a number.

Parameters
aTrgA reference containing the result.
aSrcThe number whose natural logarithm is required.

(generated from Symbian Developer Library)

◆ Log()

static IMPORT_C TInt Math::Log ( TReal &  aTrg,
const TReal &  aSrc 
)
static

Calculates the logarithm to base 10 of a number.

Parameters
aTrgA reference containing the result.
aSrcThe number whose logarithm is required.

(generated from Symbian Developer Library)

◆ Mod()

static IMPORT_C TInt Math::Mod ( TReal &  aTrg,
const TReal &  aSrc,
const TReal &  aModulus 
)
static

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
aTrgA reference containing the result.
aSrcThe p argument to the mod function.
aModulusThe q argument to the mod function.

(generated from Symbian Developer Library)

◆ Mul64()

static IMPORT_C void Math::Mul64 ( Int64  aX,
Int64  aY,
Int64 &  aOutH,
Uint64 &  aOutL 
)
static

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
aXThe first 64-bit operand.
aYThe second 64-bit operand.
aOutHThe high order 64 bits of the result.
aOutLThe low order 64 bits of the result.

(generated from Symbian Developer Library)

◆ MultPow10X()

static TInt Math::MultPow10X ( TRealX &  aTrg,
TInt  aPower 
)
static

◆ Poly()

static IMPORT_C TReal Math::Poly ( TReal  aVal,
const SPoly *  aPoly 
)
static

Evaluates the polynomial: {a[n]X^n + a[n-1]X^(n-1) + ... + a[2]X^2 + a[1]X^1 + a[0]}.

Parameters
aValThe value of the x-variable
aPolyA pointer to the structure containing the set of coefficients in the order: a[0], a[1], ..., a[n-1], a[n].

(generated from Symbian Developer Library)

◆ PolyX()

static IMPORT_C void Math::PolyX ( TRealX &  aY,
const TRealX &  aX,
TInt  aDeg,
const TRealX *  aCoef 
)
static

Evaluates the polynomial: {a[n]X^n + a[n-1]X^(n-1) + ... + a[2]X^2 + a[1]X^1 + a[0]}.

Parameters
aYA reference containing the result.
aXThe value of the x-variable.
aDegThe degree of the polynomial (the highest power of x which is present).
aCoefA 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].

(generated from Symbian Developer Library)

◆ Pow()

static IMPORT_C TInt Math::Pow ( TReal &  aTrg,
const TReal &  aSrc,
const TReal &  aPower 
)
static

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
aTrgA reference containing the result.
aSrcThe x argument of the function.
aPowerThe y argument of the function.

(generated from Symbian Developer Library)

◆ Pow10()

static IMPORT_C TInt Math::Pow10 ( TReal &  aTrg,
const TInt  exp 
)
static

Calculates the value of 10 to the power of x.

Parameters
aTrgA reference containing the result.
expThe power to which 10 is to be raised.

(generated from Symbian Developer Library)

◆ Rand()

static IMPORT_C TInt Math::Rand ( TInt64 &  aSeed)
static

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
aSeedA reference to a 64-bit seed, which is updated as a result of the call.

(generated from Symbian Developer Library)

◆ Random() [1/2]

static IMPORT_C TUint32 Math::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().

(generated from Symbian Developer Library)

◆ Random() [2/2]

static IMPORT_C void Math::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().

Parameters
aRandomValueon return, the descriptor is filled with the requested number of random bytes.

(generated from Symbian Developer Library)

◆ RandomL() [1/2]

static IMPORT_C TUint32 Math::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.

Leave condition: KErrNotReady if no data was returned as it could not be guaranteed to be cryptographically secure.

(generated from Symbian Developer Library)

◆ RandomL() [2/2]

static IMPORT_C void Math::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.

Parameters
aRandomValueon return, the descriptor is filled with the requested number of random bytes.

Leave condition: KErrNotReady if the returned random data cannot be guaranteed to be cryptographically secure.

(generated from Symbian Developer Library)

◆ Round()

static IMPORT_C TInt Math::Round ( TReal &  aTrg,
const TReal &  aSrc,
TInt  aDecimalPlaces 
)
static

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
aTrgA reference containing the result.
aSrcThe number to be rounded.
aDecimalPlacesThe number of decimal places to round to: must be zero or positive.

(generated from Symbian Developer Library)

◆ Sin()

static IMPORT_C TInt Math::Sin ( TReal &  aTrg,
const TReal &  aSrc 
)
static

Calculates the sine of a number.

Parameters
aTrgA reference containing the result.
aSrcThe argument of the sin function in radians.

(generated from Symbian Developer Library)

◆ Sqrt()

static IMPORT_C TInt Math::Sqrt ( TReal &  aTrg,
const TReal &  aSrc 
)
static

Calculates the square root of a number.

Parameters
aTrgA reference containing the result.
aSrcThe number whose square-root is required.

(generated from Symbian Developer Library)

◆ Tan()

static IMPORT_C TInt Math::Tan ( TReal &  aTrg,
const TReal &  aSrc 
)
static

Calculates the tangent of a number.

Parameters
aTrgA reference containing the result.
aSrcThe argument of the tan function in radians.

(generated from Symbian Developer Library)

◆ UDivMod64()

static IMPORT_C Uint64 Math::UDivMod64 ( Uint64  aDividend,
Uint64  aDivisor,
Uint64 &  aRemainder 
)
static

Divides aDividend by aDivisor.

The quotient is returned, and the remainder is stored in aRemainder.

Parameters
aDividendThe 64-bit dividend.
aDivisorThe 64-bit divisor.
aRemainderThe 64-bit remainder.

(generated from Symbian Developer Library)

◆ UMul64()

static IMPORT_C void Math::UMul64 ( Uint64  aX,
Uint64  aY,
Uint64 &  aOutH,
Uint64 &  aOutL 
)
static

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
aXThe first 64-bit operand.
aYThe second 64-bit operand.
aOutHThe high order 64 bits of the result.
aOutLThe low order 64 bits of the result.

(generated from Symbian Developer Library)


The documentation for this class was generated from the following files: