1.4.3.8 _LIBQ_Q16Exp Function
Calculates the exponential function e^x.
Description
_Q16 _LIBQ_Q16Exp(_Q16 x);
Calculates the exponential function e^x. The calculation will saturate if the resulting value is outside the range of the _Q16 representation. For x > 10.3972015380859375, the resulting value will be saturated to 0x7fffffff. For x < -10.3972015380859375 the resulting value will be saturated to 0.
Preconditions
None.
Parameters
x The exponent value
Returns
_LIBQ_Q16Exp returns the _Q16 fixed point result from the calculation e^x.
Remarks
The function _LIBQ_Q16Div is called by this routine and thus must be linked into the executable image.
Execution Time (cycles): 170 typical (18 to 292)
Program Memory 446 bytes
Error <= 0.000015258789 (accurate to least significant _Q16 bit within the non-saturated range)
Example
_Q16 expResult;
expResult = _LIBQ_Q16Exp((_Q16)0x00010000);
_// _LIBQ_Q16Exp(1.000000) = 2.718277 (0x0002b7e1)_
C
_Q16 _LIBQ_Q16Exp (_Q16 x );