Hello,
I thought it could interest you to know how I got these formulas (with x>0):
DEG->DMS(x)=(90*x+INT(60*x)+100*INT(x))/250
DMS->DEG(x)=(250*x-INT(100*x)-60*INT(x))/90
To compute DEG->DMS(x):
D = unknown degrees as integer
M = unknown minutes as integer
s = unknown seconds as decimal
Known x=D+M/60+s/3600
D = INT(x)
M = INT(60*x-60*D)
M = INT(60*x-60*INT(x))
M = INT(60*x)-60*INT(x)
s = 3600*x-3600*D-60*M
s = 3600*x-3600*INT(x)-60*(INT(60*x)-60*INT(x))
s = 3600*x-3600*INT(x)-60*INT(60*x)+3600*INT(x)
s = 3600*x-60*INT(60*x)
DMS(x) = D+M/100+s/10000
DMS(x) = INT(x)+(INT(60*x)-60*INT(x))/100+(3600*x-60*INT(60*x))/10000
DMS(x) = (10000*INT(x)+100*INT(60*x)-6000*INT(x)+3600*x-60*INT(60*x))/10000
DMS(x) = (3600*x+40*INT(60*x)+4000*INT(x))/10000
DMS(x) = (90*x+INT(60*x)+100*INT(x))/250
It's mathematically exact, but special care is needed in evaluating INT(60*x) on a calculator.
=> It seems better to round 60*x to last internal digit before applying INT.
To compute DMS->DEG(x):
D = unknown degrees as integer
M = unknown minutes as integer
s = unknown seconds as decimal
Known x=D+M/100+s/10000
D = INT(x)
M = INT(100*x-100*D)
M = INT(100*x-100*INT(x))
M = INT(100*x)-100*INT(x)
s = 10000*x-10000*D-100*M
s = 10000*x-10000*INT(x)-100*(INT(100*x)-100*INT(x))
s = 10000*x-10000*INT(x)-100*INT(100*x)+10000*INT(x)
s = 10000*x-100*INT(100*x)
DEG(x) = D+M/60+s/3600
DEG(x) = INT(x)+(INT(100*x)-100*INT(x))/60+(10000*x-100*INT(100*x))/3600
DEG(x) = (3600*INT(x)+60*INT(100*x)-6000*INT(x)+10000*x-100*INT(100*x))/3600
DEG(x) = (10000*x-40*INT(100*x)-2400*INT(x))/3600
DEG(x) = (250*x-INT(100*x)-60*INT(x))/90
Thanks for reading !
Edited: 2 May 2012, 3:08 a.m.