Pages: [1]   Go Down
Author Topic: parseFloat() problem  (Read 254 times)
0 Members and 1 Guest are viewing this topic.
Belgium
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 :-)
Logged

BCC AZ USA
Offline Offline
Edison Member
*
Karma: 37
Posts: 1301
It gets hot so it must be working
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Belgium
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 :-)
Logged

Pages: [1]   Go Up
Jump to: