user16897: I found the .toFloat() but that's not accurate enough.
String StrEx = "57.10598";
float FloatEx = StrEx.toFloat();

Serial.println(String(FloatEx)); //outputs 57.11
Serial.println(StrEx);           //outputs 57.10598


user4143: It is a common misconception that, because when you print a float you only get 2 decimal places, that the float only has 2 decimal places.
That is not true. A float doesn't have a number of decimal places - that is how it gets its name - floating point: the decimal point floats around as needed.
The problem is actually that, by default, all the Arduino print and string conversion functions are set to 2 decimal places. Unless you specify the number of decimal places you want to print (or convert to) you get 2 decimal places.
By specifying 5 decimal places when you print or convert to a string you get 5 decimal places.  It still won't always give you exactly the same number, but that is because a 32-bit float cannot store all possible numbers, so some are only an approximation. It's still a whole lot more accurate than 57.10598 -> 57.11 though.

16897: <p>I found the .toFloat() but that's not accurate enough.</p>

<pre><code>String StrEx = "57.10598";
float FloatEx = StrEx.toFloat();

Serial.println(String(FloatEx)); //outputs 57.11
Serial.println(StrEx);           //outputs 57.10598
</code></pre>
 4143: <p>It is a common misconception that, because when you print a float you only get 2 decimal places, that the float only has 2 decimal places.</p>

<p>That is not true. A float doesn't have a number of decimal places - that is how it gets its name - floating point: the decimal point floats around as needed.</p>

<p>The problem is actually that, by default, all the Arduino print and string conversion functions are set to 2 decimal places. Unless you specify the number of decimal places you want to print (or convert to) you get 2 decimal places.</p>

<p>By specifying 5 decimal places when you print or convert to a string you get 5 decimal places.  It still won't always give you exactly the same number, but that is because a 32-bit float cannot store all possible numbers, so some are only an approximation. It's still a whole lot more accurate than 57.10598 -> 57.11 though.</p>
