1.4.3.4 _LIBQ_Q15FromString Function

ASCII to _Q15 conversion.

Description

_Q15 _LIBQ_Q15FromString(char *s);

Convert an ASCII string into a _Q15 fixed point value. The ASCII string must be in an -N.NNNNNN format. Leading spaces are ignored. The conversion stops at either the first non-conforming character in the string or the Null string terminator. There must be no spaces within the string value itself.

Preconditions

None.

Parameters

s A pointer to the ASCII input string representing the _Q15 fixed point value.

Returns

_LIBQ_Q15FromString returns the _Q15 fixed point value represented by the input string.

Remarks

Execution Time (cycles): 296 typical (28 to 346)

Program Memory 172 bytes

Example

_Q15 x;

x = _LIBQ_Q15FromString("0.125"); _// x will equal 0.125 using_

_// an internal value of 0x1000_

x = _LIBQ_Q15FromString("-1.0"); _// x will equal -1.0 using_

_// an internal value of 0x8000_

x = _LIBQ_Q15FromString("0.999969"); _// x will equal 0.999969 using_

_// an internal value of 0x7FFF_

C

_Q15 _LIBQ_Q15FromString ( char * s );