Printing floats.

Having troubles working with float varibles, we’re trying to solve the problems, but $f doesn’t print float varibles.
If not, then how?

Read the docs for the C compiler/C library. Floating point format is not supported in the C18 printf.

You can roll your own if you know the range of values (like between .01 and 99.99) by converting to a fixed point integer for example, or by just using fixed point arithmatic instead of float or double.

For example, we have PID factors that are 0.00 to 9.99 in range using fixed point; something like correction = (p * proportion)/100; and proportation is a signed int in the range of 0…999 which represents 0.00 to 9.99 as previously stated. I use the following to convert proportion to a friendly output value. I don’t have to worry about sign since it is always positive by design. Just an example.

static char _string[10];
static void _format( int value )
unsigned char tmp, tmp1;

    tmp  = value/100;
    _string[0] = '0'+tmp;
    tmp1 = value - (tmp*100);
    tmp  = tmp1/10;
    _string[1] = '.';
    _string[2] = '0'+tmp;
    tmp = tmp1 - (tmp*10);
    _string[3] = '0'+tmp;
    _string[4] =  0;

…or I could just printf( "proportion=%03d
", proportion) and remember that there is a decimal place in front of the last two digits.