1.4.3.27 _LIBQ_Q5_10_log2_Q16 Function

Calculates the value of log2(x).

Description

_Q5_10 _LIBQ_Q5_10_log2_Q16 (_Q16 x);

Calculates the log2(x), where log2(x) = ln(x) * log2(e). x is of type _Q16 and must be positive. The resulting value is of type _Q5_10.

Preconditions

The input x must be positive.

Parameters

x The input value from which to calculate log2(x).

Returns

_LIBQ_Q5_10_log2_Q16 returns the _Q5_10 fixed point result from the calculation log2(x).

Remarks

Execution Time (cycles): 227 typical (14 to 268)

Program Memory 164 bytes

Error <= 0.0009765625 (accurate to least significant _Q5_10 bit)

Example

_Q5_10 resultLog2;

resultLog2 = _LIBQ_Q5_10_log2_Q16 ((_Q16)0x40000000); 

_// _LIBQ_Q5_10_log2_Q16(16384.000000) =_ _14.000000 (0x3800)_

C

_Q5_10 _LIBQ_Q5_10_log2_Q16 (_Q16 x );