How can I print (that is, to stdout) a float in C without having it be promoted to a double when passed to printf?
The issue here is that variadic functions in C promote all float parameter to double, which incurs two unnecessary conversions. For example, if you turn on -Wdouble-promotion in GCC and compile
float f = 0.f;
printf("%f", f);
you will get
warning: implicit conversion from 'float' to 'double' when passing argument to function
I have relatively little processing power to play with (a 72MHz ARM Cortex-M3), and I am definitely bottlenecking on ASCII output of floating point data. As the architecture lacks a hardware FPU to begin with, having to convert between single and double precision does not help matters.
Is there a way to print a float more efficiently in straight C?