how to convert degree minutes seconds into decimal value

Status
Not open for further replies.

engineer khan

Member level 3
Joined
Aug 31, 2012
Messages
66
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Visit site
Activity points
1,833
Hello All dears,

I m working to design a device that take location lat long, i successfully obtained lat-long but the problem is that lat-long value is in degree/minutes/seconds i need it in decimal number, let suposed i get lat=2450.1234 which in decimaol is "24.83336761111111" how can i go from first value to the latter one.....i sought on net where i found a formula degree/+minutes/60+second/3600 ,the question is that how to covert 2450.1234 to 24.83336761111111 in c coding i m using pic18f mikroc compiler
 

Code:
void LongToTime (long Ticks, char * h, char * m, char * s)
{
 while (Ticks--)
{
s++;
if (*s == 60) {*s = 0; *m++;}
if (*m == 60) {*m = 0; *h++;}
}
}
This is untested. Wrote in 10 seconds after lunch (intelligent descreased greatly).

Few minutes later...
Ticks = 60*60*h + 60*m + s;
 
Last edited:

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…