User manual

Table Of Contents
634
mikoC PRO for PIC32
MikroElektronika
FloatToStr
Prototype
unsigned char FloatToStr(oat fnum, unsigned char *str);
Description Converts a oating point number to a string.
The output string is left justied and null terminated after the last digit.
Parameters - fnum: oating point number to be converted
- str: destination string
Returns - 3 if input number is NaN
- 2 if input number is -INF
- 1 if input number is +INF
- 0 if conversion was successful
Requires Destination string should be at least 14 characters in length.
Example
oat ff1 = -374.2;
oat ff2 = 123.456789;
oat ff3 = 0.000001234;
char txt[15];
...
FloatToStr(ff1, txt); // txt is “-374.2”
FloatToStr(ff2, txt); // txt is “123.4567”
FloatToStr(ff3, txt); // txt is “1.234e-6”
Notes Given oating point number will be truncated to 7 most signicant digits before conversion.
WordToStrWithZeros
Prototype
void WordToStrWithZeros(unsigned int input, char *output);
Description Converts input word to a string. The output string has xed width of 6 characters including null character
at the end (string termination).
The output string is right justied and remaining positions on the left (if any) are lled with zeros.
Parameters - input: unsigned integer to be converted
- output: destination string
Returns Nothing.
Requires Destination string should be at least 6 characters in length.
Example
unsigned short t = 437;
char txt[6];
...
WordToStrWithZeros(t, txt); // txt is “0437” (one zero here)
Notes None.