1.4.4.6 Fract_2toX_Q15bfp Function

fract_q15bfp_t Fract_2toX_Q15bfp( fract_q15bfp_t x )

Summary

Calculates pow(2,x) with fixed point math.

Description

Calculates pow(2,x) using fixed point math, from Q15 block floating point x, returning Q15 block floating point result.

Preconditions

none.

Parameters

x exponent, in Q15 block floating point format

Returns

pow(2,x), in Q15 block floating point format

Remarks

None.

Example

fract_q15bfp_t x, y;

x.m = 16384; _// 0.5_

x.e = 0;

y = Fract_2toX_Q15bfp(x);

_// pow(2,0.5) = sqrt(2) = 46341/32768;_

_// y.m = 0x5A85 = 23173_

_// y.e = 1_

_// y = (23173/32768)<<1 = 1.414368 (vs. 1.414214)_

x.m = 24576; _// 0.75_

x.e = 0;

y = Fract_2toX_Q15bfp(x);

_// pow(2,0.75) = 1.681793 = 55109/32768;_

_// y.m = 0x6BA4 = 27556_

_// y.e = 1_

_// y = (27556/32768)<<1 = 1.681885 (vs. 1.681793)_

C

fract_q15bfp_t Fract_2toX_Q15bfp (fract_q15bfp_t x );