1.4.4.3 Fract_10toX_Q15bfpFromQ15d16 Function
fract_q15bfp_t Fract_10toX_Q15bfpFromQ15d16( fract_q15d16_t x )
Summary
Calculates pow(2,x) with fixed point math.
Description
Calculates pow(2,x) using fixed point math, with x as Q15.16, returning result as Q15 block floating point.
Preconditions
None.
Parameters
x exponent as Q15.16
Returns
pow(2,x) as Q15 block floating point
Remarks
Fract_10toX(x) is basically Fract_2toX( log2(10)*x ).
Example
fract_q15bfp_t Y; x = 0x00008000; _// 0.5_ Y = Fract_10toX_Q15bfpFromQ15d16(x); _// Y.m = 0x6532 = 25906_ _// Y.e = 2_ _// Y = ( 25906 / 32768 )<<2 = 3.162353 (vs. 3.162277) , rel error = 1/41688_ x = 0x0003243F; _// 205,887 / 65536 = 3.141586 (vs. 3.14159)_ Y = Fract_10toX_Q15bfpFromQ15d16(x); _// Y.m = 0x5696 = 22167 / 32768 = 0.676483_ _// Y.e = 0x000B = 11_ _// Y = (22167 / 32768)<<11 = 1385.4375 (vs. 1385.435475), rel error = 1/684,023_
C
fract_q15bfp_t Fract_10toX_Q15bfpFromQ15d16 (fract_q15d16_t x );