1.4.3.26 _LIBQ_Q4_11_ln_Q16 Function

Calculates the natural logarithm ln(x).

Description

_Q4_11 _LIBQ_Q4_11_ln_Q16 (_Q16 x);

Calculates the natural logarithm ln(x). x is of type _Q16 and must be positive. The resulting value is of type _Q4_11.

Preconditions

The input x must be positive.

Parameters

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

Returns

_LIBQ_Q4_11_ln_Q16 returns the _Q4_11 fixed point result from the calculation ln(x).

Remarks

Execution Time (cycles): 301 typical (14 to 346)

Program Memory 176 bytes

Error <= 0.00048828 (accurate to least significant _Q4_11 bit)

Example

_Q4_11 resultLN;

resultLN = _LIBQ_Q4_11_ln_Q16 ((_Q16)0x00004000); 

_// _LIBQ_Q4_11_LN_Q16(0.250000) = -1.386230_ _(0xf4e9)_

C

_Q4_11 _LIBQ_Q4_11_ln_Q16 (_Q16 x );