Datasheet

FloatToStr
565
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroC PRO for AVR
CHAPTER 6
Prototype
unsigned char FloatToStr(float fnum, unsigned char *str);
Returns
- 3 if input number is NaN
- 2 if input number is -INF
- 1 if input number is +INF
- 0 if conversion was successful
Description
Converts a floating point number to a string.
Parameters :
- fnum: floating point number to be converted
- str: destination string
The output string is left justified and null terminated after the last digit.
Note: Given floating point number will be truncated to 7 most significant digits
before conversion.
Requires Destination string should be at least 14 characters in length.
Example
float ff1 = -374.2;
float ff2 = 123.456789;
float 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"