1.4.3.7 _LIBQ_Q16Div Function

_Q16 fixed point divide.

Description

_Q16 _LIBQ_Q16Div (_Q16 dividend, _Q16 divisor);

Quotient (_Q16) = Dividend (_Q16) / Divisor (_Q16).

Preconditions

Divisor must not equal 0.

Parameters

dividend The divide operation dividend (_Q16)

divisor The divide operation divisor (_Q16)

Returns

_Q16 quotient of the divide operation

Remarks

The _LIBQ_Q16Div operation saturates its result.

Execution Time (cycles): 143 typical (80 to 244)

Program Memory 204 bytes

Error <= 0.000015258789 (accurate to least significant _Q16 bit within the non-saturated range)

Example

_Q16 quotient, dividend, divisor;

dividend = (_Q16)0x00010000; _// 1_

divisor = (_Q16)0x00008000; _// 0.5_

quotient = _LIBQ_Q16Div (dividend, divisor);

_// quotient now equals 2; i.e., (_Q16)0x00020000;_

C

_Q16 _LIBQ_Q16Div (_Q16 dividend , _Q16 divisor );