1.4.3.10 _LIBQ_Q16Sqrt Function

Square root of a positive _Q16 fixed point value.

Description

_Q16 _LIBQ_Q16Sqrt(_Q16 x);

Calculate the square root of a positive _Q16 fixed point value, and return the _Q16 result.

Preconditions

The input value must be positive.

Parameters

x The _Q16 fixed point value input from which to find the square root.

Returns

_LIBQ_Q16Sqrt returns the _Q16 fixed point value which is the square root of the input parameter.

Remarks

Execution Time (cycles): 240 typical (104 to 258)

Program Memory 152 bytes

Error <= 0.000015258789 (accurate to least significant _Q16 bit)

Example

_Q16 squareRoot;

squareRoot = _LIBQ_Q16Sqrt((_Q16)0x01000000); _// The square root of 256.0 is 16.0 (0x00100000)_

squareRoot = _LIBQ_Q16Sqrt((_Q16)0x00004000); _// The square root of 0.25 is 0.5 (0x00008000)_

squareRoot = _LIBQ_Q16Sqrt((_Q16)0x5851f42d); _// The square root of 22609.953125 is 150.366074_

_(0x00965db7)_

C

_Q16 _LIBQ_Q16Sqrt (_Q16 x );