1.4.3.9 _LIBQ_Q16Power Function

Calculates the value of x raised to the y power (x^y).

Description

_Q16 _LIBQ_Q16Power (_Q16 x, _Q16 y);

Calculates the x raised to the y power. Both x and y are of type _Q16. x must be positive. The calculation will saturate if the resulting value is outside the range of the _Q16 representation.

Preconditions

x must be positive.

Parameters

x The _Q16 input value x from which to calculate x raised to the y.

y The _Q16 input value y from which to calculate x raised to the y.

Returns

_LIBQ_Q16Power returns the _Q16 fixed point result from the calculation x raised to the y.

Remarks

Execution Time (cycles): 882 typical (586 to 1042)

Program Memory 1038 bytes

Error <= 0.000015258789 (accurate to least significant _Q16 bit within the non-saturated range)

Example

_Q16 resultPower;

resultPower = _LIBQ_Q16Power ((_Q16)0x00020000, (_Q16)0xffff0000); 

_// _LIBQ_Q16Power(2.000000,_ _-1.000000) = 0.500000 (0x00008000)_

C

_Q16 _LIBQ_Q16Power (_Q16 x , _Q16 y );