1.4.4.5 Fract_2toMinusX_Q15 Function
fract_q15_t Fract_2toMinusX_Q15( fract_q15_t x );
Summary
Calculates pow(2,-x) with fixed point math.
Description
Calculates pow(2,-x) with fixed point math, using three term Taylor Series and 256 entry lookup table.
Preconditions
None.
Parameters
x Exponent in calculating 2^-x. If x < 0 then -x is used.
Returns
Value of pow(2,-x)
Remarks
If 0 <= x < 1, then pow(2,-x) is in the range 0.5 < pow(2,-x) <= 1.
Example
fract_q15_t x,y; x = 3277; _// 0.1_ y = Fract_2toMinusX_Q15(x); _// pow(2,-0.1) = 0.933033 = 30574 / 32768_ _// y = 0x776D = 30573_ x = 6554; _// 0.2_ y = Fract_2toMinusX_Q15(x); _// pow(2,-0.2) = 0.870551 = 28526 / 32768_ _// y = 0x6F6E = 28526_ x = 9830; _// 0.3_ y = Fract_2toMinusX_Q15(x); _// pow(2,-0.3) = 0.812252 = 26616 / 32768_ _// y = 0x67F9 = 26617_ x = 13107; _// 0.4_ y = Fract_2toMinusX_Q15(x); _// pow(2,-0.4) = 0.757858 = 24834 / 32768_ _// y = 0x6102 = 24834_ x = 16384; _// 0.5_ y = Fract_2toMinusX_Q15(x); _// pow(2,-0.5) = 0.707107 = 23170 / 32768_ _// y = 0x5A81 = 23169_ x = 3277 + 16384; _// 0.1 + 0.5 = 0.6_ y = Fract_2toMinusX_Q15(x); _// pow(2,0.6) = 0.659754 = 21619 / 32768_ _// y = 0x5472 = 21618_ x = 6554 + 16384; _// 0.2 + 0.5 = 0.7_ y = Fract_2toMinusX_Q15(x); _// pow(2,-0.7) = 0.615572 = 20171 / 32768_ _// y = 0x4ECA = 20170_ x = 9830 + 16384; _// 0.3 + 0.5 = 0.8_ y = Fract_2toMinusX_Q15(x); _// pow(2,-0.8) = 0.574349 = 18820 / 32768_ _// y = 0x4984 = 18820_ x = 13107 + 16384; _// 0.4 + 0.5 = 0.9_ y = Fract_2toMinusX_Q15(x); _// pow(2,-0.9) = 0.535887 = 17560 / 32768_ _// y = 0x4498 = 17560_ x = 32767; _// 0.5 + 0.5 = 1.0_ y = Fract_2toMinusX_Q15(x); _// pow(2,-1.0) = 0.5 = 16384 / 32768_ _// y = 0x4001 = 16385_
C
fract_q15_t Fract_2toMinusX_Q15 (fract_q15_t x );