1.4.4.7 Fract_2toX_Q15bfpFromQ15d16 Function
fract_q15bfp_t Fract_2toX_Q15bfpFromQ15d16( fract_q15d16_t x )
Summary
Calculates pow(2,x) with fixed point math.
Description
Calculates pow(2,x) using fixed point math, based on input in Q15.16 format, returning result in Q15 block floating point format.
Preconditions
None.
Parameters
x exponent, in Q15.16 format
Returns
pow(2,x), in Q15 block floating point format
Remarks
None.
Example
fract_q15d16_t x; fract_q15bfp_t Y; x = 0x00008000; _// 0.5 in Q15.16_ Y = Fract_2toX_Q15bfpFromQ15d16(x); _// pow(2,0.5) = sqrt(2) = 1.414213 = 46341 / 32768 = 0x5A82<<1_ _// Y.m = 0x5A85 = 23173_ _// Y.e = 1_ _// Y = ( 23173 / 32768 )<<1 = 1.414367 (vs. 1.414213)_ x = 0x00014000; _// 1.25 in Q15.16_ Y = Fract_2toX_Q15bfpFromQ15d16(x); _// pow(2,1.25) = 2.378414 = 77936 / 32768 = 0x4C1C<<2_ _// Y.m = 0x4C1 = 19484_ _// Y.e = 2_ _// Y = ( 19484/32768 ) << 2 = 2.378418 (vs. 2.378414)_
C
fract_q15bfp_t Fract_2toX_Q15bfpFromQ15d16 (fract_q15d16_t x );