toFloat() only return 2 decimal places

I have a problem where I want to convert a string "32.89234" to float, and when I use string.toFloat() it only returns 32.89, is there a way that I can make it return all decimal places?


How are you determining that .toFloat() only produces two decimal places? If you are printing the result, .print() defaults to two decimal places, if you want more you have to explicitly specify that:

Serial.print(floatNumber, 5); //print with 5 decimal places

Don't be too sure. The Arduino reference says,
"Note that "123.456" is approximated with 123.46"

Looks like .toFloat() and .toDouble() do not round at two decimal digits, at least on an UNO:

String f = "32.89234";

void setup()

  float ff = f.toFloat();
  double fd = f.toDouble();

  Serial.println(ff, 8);
  Serial.println(fd, 8);

void loop() {}



That's a relief if you are using the String class.