User manual
718
mikoC PRO for dsPIC
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 justied 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 signicant digits before conversion.