The Teensy 3.5 and 3.6 only support single precision floating point in hardware. So as a compromise, Paul turns on the option
-fsingle-precision-constant which forces constants with an explicit suffix to be single precision. This way, the expression:
Code:
float f;
// ...
f += 1.0;
is done in single precision. Without the option,
f would be converted to
double, and then the
__adddf3 function would be called to emulate double precision, and then the value would be converted back to single precision.
C's rules about constants being double harken back to the initial machines Dennis Ritchie developed C on (PDP-7 and then mostly PDP-11). On the models that they had in Bell Labs, double precision was the default, and you had to switch the CPU to single precision if you wanted to do 32-bit calculations. In the same vein, until Intel came out with the SSE instruction set, all floating point calculations were done in 80-bit mode. So the default arithmetic is
double, and constants defaulted to that as well. It wasn't until the first ANSI (later ISO) C standard that single precision arithmetic did not automatically promote to double.
But on machines that support both
float and
double and
double is much slower than
float, it can be a problem unless people use the '
F' suffix.
While C's rules are somewhat arbitrary, it is at least better than PL/1, in which constants with 6 or fewer digits were converted to single precision and 7 or more were converted to double precision. When I wrote the Data General C compiler in PL/1 some 30 years, I remember having to specify things as 0.100000000 to get the proper constant.
Fortunately, the arm 32-bit compiler does not support IEEE 128-bit floating point, and
long double is the same as
double. So when you declare a constant with the '
L' it doesn't change it to a different representation. I've been working on/off with IEEE 128-bit floating point for the last few years (I work for IBM on the PowerPC GCC compiler, and the soon to be shipping power9 has IEEE 128-bit floating point hardware).