Printing floats with Serial.print(floatvariable*1000.0,3) results in "invalid operands"

In my code for an Arduino Due I often use print statements like Serial.print(floatvar*1000.0,3). The float variable floatvar shall be multiplied with 1000.0 and printed with 3 decimals.

This work all the time until about a week ago.

Now the compiler reports: error: invalid operands of types ‘float*’ and ‘double’ to binary ‘operator*’

What is wrong?

Then in the expression Serial.print(floatvar*1000.0,3) the floatvar must be of type float *, a pointer to a float. You have to dereference the pointer to obtain the float it points to, as in

Serial.print(*floatvar*1000.0,3);

It could also be a previous error that your floatvar is actually a float *, so carefully check your code.

Another thing to note is that using a double (64-bit) type constant, like 1000.0, is asking for punishment. If the left side of the operand is a float (32-bit) and the desired number of decimal points is “3” anyways, then it should be 1000.0f, a float type constant. By writing it as 1000.0 you are making the compiler pull in expensive double-floatingpoint library code that deals with data type conversions and multiplying two doubles. The Arduino Due is a Cortex M3, so it has no FPU to accelerate any of that (unlike a Cortex-M4F would have), and the code to do double operations with just integer operations is huge. It can easily blow up the flash usage of the firmware.