1.4.4.14 Fract_log10fix Function

int32_t Fract_log10fix (int32_t x, size_t precision)

Calculates fixed point base 10 logarithm using number of fractional bits specified by precision argument.

Description

Calculates fixed point base 10 logarithm using number of fractional bits specified by precision argument. Log base 10 is calculated using the log base 2 function Fract_log2fix.

Preconditions

None.

Parameters

x Fixed point input, if x == 0, function returns INT32_MIN to represent negative.

infinity. If x is input as a negative number it will be cast to be a unsigned 32 bit integer.

precision number of fractional bits in input and output, 1<= precision <= 31.

if precision < 1 or precision > 31 function returns INT32_MAX.

Returns

Logarithm base 10 of input, in same Q format as input.

Remarks

If precision = N, then the input and output are Q(31-N).N.

For example, if precision = 16 then the input and output are Q15.16.

This means that there are 16 fractional bits (the LS word) and the upper 16 bits (MS word) represents an int16_t integer.

Example

See the code example under Fract_log2fix.

C

int32_t Fract_log10fix (int32_t x , size_t precision );