Float variables are shortened to only 4 digits

Whenever I create a float variable, it is rounded to 4 digits. Shouldn't floats be able to store more precise decimals than just 4 digits? See below

"myFloat" is a float is declared and then printed to Serial:
image

But the Serial Monitor shows that the myFloat has been rounded to only 4 digits:

Is there a way to stop this rounding? It is the same when I make it a double instead of a float too.

Yes, all you have to do is read the documentation
https://www.arduino.cc/reference/en/language/functions/communication/serial/print/

Try … Serial.println(myfloat,4);

Remember that an Arduino UNO/Nano/Mega 'float' can only hold about 6.8 significant digits. You can say:
Serial.println(myfloat, 10);
and it will show 10 digits after the decimal point, but after the first 6 or 7 digits (including the two before the decimal point), the digits will be fairly random.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.