CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

GPS data to FLOAT

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ljbeng



Joined: 10 Feb 2004
Posts: 205

View user's profile Send private message

GPS data to FLOAT
PostPosted: Fri Mar 05, 2004 2:16 pm     Reply with quote

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?
Ttelmah
Guest







Re: GPS data to FLOAT
PostPosted: Fri Mar 05, 2004 3:48 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group