A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

# Tag Info

1

There are two issues at play here: 1 – Limited precision of the float data type A float has a precision of roughly 10−7, and any number that is not an exact float is supposed to be rounded to the nearest float. For example, the two floats closest to 1.234567 are 10356298 × 2−23 = 1.2345669269561767578125 and 10356299 × 2−23 = 1.23456704616546630859375. The ...

0

You get this, because a float uses a certain number of bytes (I don't have an Arduino at hand), I think it is 4 bytes. In these bytes, only a certain accuracy can be stored, so the least significant digits gets rounded (binary, resulting in different end digits). Only for e.g. Arduino Due: You can use doubles instead, see https://www.arduino.cc/reference/...

0

If you are using atof() to convert the string to a floating-point number, you would only get 6 or 7 digits of precision. And the numbers in your examples already have that much precision.

0

It seems that I must convert to string first then use atof.

Top 50 recent answers are included