Ttelmah Guest
|
Re: GPS data to FLOAT |
Posted: Fri Mar 05, 2004 3:48 pm |
|
|
ljbeng wrote: | My GPS receiver sends lat and lon to my 18F452. I then change them to float. roverlon = atof(gps). Here are some results:
GPS atof(gps)
"4007.6377" 4007.637798
"4007.6379" 4007.638067
"4007.6384" 4007.638543
"9744.2617" 9744.261443
"9744.2607" 9744.26043
It is a WAAS receiver which makes the 4 decimal point fairly significant. Can I expect anything better than this? |
No.
There have been lots of posts about this in various contexts in the past. The internal floating point format, is a single precision format, with 23bits used to hold the numeric data. This gives a 'best case' resolution, of 1 in 8388608. This is normally referred to as a 6.5 digit resolution. This is exactly what you are seeing.
If you want to store the numbers more accurately, you would have to either write your own numeric format, or possibly consider using a scaled integer (a 31 bit integer, manages just over 9 digits, provided the value is scaled correctly.
It is worth remembering that the six+ digit resolution is available for the decimal part, if you (for instance), stored the part in front of the decimal point as an integer, and then the value after the DP as a float.
It is also worth considering how you are going to work with the format. The data 'layout', is DDDMM.SS, hence you are going to have to either code your own arithmetic routines, or do the arithmetic in 'sections', dealing with degrees, minutes, and seconds, and handling the 'carry' yourself. This will code much faster handled as integer data in a suitable structure, than as a float.
Best Wishes |
|