Go Down

Topic: parseFloat() problem (Read 399 times) previous topic - next topic

petervanlievenoogen

I try to parse data from a SD card to a double on a Due
the data on the card looks like this 50.905372
but if I check the double the value is 50.905365
this data are GPS position waypoints.
I can not post the code, its more than 3000 lines ...

Is there a work around for this problem?   

greetings from belgium :-)

groundfungus

Save the data to SD as a long or unsigned long by multiplying the number by 1,000,000 before saving.  Uses the same 4 bytes but you don't have the inaccuracy of floats.  Divide by 1,000,000 and cast as float  when you retrieve the number.

petervanlievenoogen


Save the data to SD as a long or unsigned long by multiplying the number by 1,000,000 before saving.  Uses the same 4 bytes but you don't have the inaccuracy of floats.  Divide by 1,000,000 and cast as float  when you retrieve the number.


I was just trying this, and it works, but the data is a CSV with 1000 waypoint.
they need to read from the SD card and put in 5 array's.
The CSV is output from a datalogger, so we need to do some editing...
On the racetrack while racing , not so handy
If the data was allway's the same format I could use two times a parseInt()
The parseInt() takes the decimal point as terminator...
Working on this solution now, thanks for the advice :-)

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy