I am trying to get a gps reading from a string to a float on my Arduino. The string has all handles all of the digits just fine, but when I divide it to get a float I lose 4 of my digits. Here is my code:
gpsStrings[0].replace(".", "");
lat = gpsRawData[0].toFloat();
lat = lat / 1000000.0;
Using .toFloat on a string that still has the decimal point in it results in the same thing, only two numbers after the decimal point.
Example numbers:
42427898 :: 42.43 - what happens
42427898 :: 42.427898 - what I want to happen
Alright I was wrong, the default print function only uses two digits of precision. So I had to add how many digits I wanted to the statement.
print(lat, 20);
Will give 20 digits of precision on the serial monitor where
print(lat)
only gives two.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With