07.03.2014 Views

IQmath Library

IQmath Library

IQmath Library

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

atoIQN<br />

String to IQN<br />

Description<br />

Declaration<br />

This function converts a string to IQ number.<br />

Global IQ function (IQ format = GLOBAL_Q)<br />

float _atoIQ( char *S)<br />

Q format specific IQ function (IQ format = IQ1 to IQ30)<br />

float _atoIQN( char *S)<br />

Input<br />

This function recognizes (in order) an optional sign, a string of digits<br />

optionally containing a radix character.<br />

Valid Input strings:<br />

“12.23456”, “-12.23456”, “0.2345”, “0.0” , “0” , “127” , “-89”<br />

Output<br />

The first unrecognized character ends the string and returns zero. If the<br />

input string converts to a number greater then the max/min values for the<br />

given Q value, then the returned value will be limited to the min/max<br />

values<br />

Global IQ function (IQ format = GLOBAL_Q)<br />

Fixed point equivalent of input string in GLOBAL_Q format<br />

Q format specific IQ function (IQ format = IQ1 to IQ29)<br />

Fixed point equivalent of input string in IQN format<br />

Usage<br />

This is useful for programs that need to process user input or ASCII<br />

strings.<br />

Example:<br />

The following code prompts the user to enter the value X:<br />

char buffer[N];<br />

_iq X;<br />

printf("Enter value X = ");<br />

gets(buffer);<br />

X = _atoIQ(buffer);<br />

// IQ value (GLOBAL_Q)<br />

©Texas Instruments Inc., June 2002 16

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!