I’ve found a strange issue that seems like a nasty bug in dtostrf. I’ve noticed it when converting gps longitudes into strings. I don’t have an arduino zero to check on it.
Find bellow the code that reproduces the error, in my Autonomo (with the latests updates in all libraries) I get from the serial monitor:
long=-5.575418
String from dtostrf: -5.424
so the double is converted to the wrong string.
Here is the test code:
#include <avr/dtostrf.h>
char strLng[12];
float gpslong=-5.575418;
void setup() {
SerialUSB.begin(115200);
}
void loop() {
dtostrf (gpslong, 11,6, strLng);
SerialUSB.print("long=");
SerialUSB.println(gpslong,6);
SerialUSB.print("String from dtostrf: ");
SerialUSB.println(strLng);
delay(1000);
}
Thanks