# Algorithm (or fn) for Degrees-mins-secs to decimal?

## Recommended Posts

Does AutoIt have (or failing this--can someone code me) a degrees-minutes-secs converter?

e.g. 50o 42' 43.33 = 50.712008

##### Share on other sites

Does AutoIt have (or failing this--can someone code me) a degrees-minutes-secs converter?

e.g. 50o 42' 43.33 = 50.712008

We don't create scripts on request here. We help you write your own. A minute is just 1/60th of a degree, and a second is just 1/60th of a minute. So the math is easy: 50 + 42/60 + (43.33/60)/60

Try to code it and come back with a more specific question about using AutoIt if you need to.

P.S. If you need someone to code it for you, see the Rent-A-Coder link in my sig.

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

##### Share on other sites

```;50o 42' 43.33 = 50.712008

\$result = DMS2DEC(50,42,43.33)
ConsoleWrite(\$result & @CRLF)

\$result2 = DEC2DMS(\$result)
ConsoleWrite(\$result2 & @CRLF)

Func DMS2DEC(\$fDegrees, \$fMinutes, \$fSeconds)
Return \$fDegrees + (\$fMinutes/60) + (\$fSeconds/3600)
EndFunc

Func DEC2DMS(\$fDec)
Local \$fDegrees, \$fMinutes, \$fSeconds
\$fDegrees = Int(\$fDec)
\$fMinutes = (\$fDec - \$fDegrees) * 60
\$fSeconds = StringFormat("%.2f",(\$fMinutes - Int(\$fMinutes)) * 60)
Return StringFormat("%s° %s' %s""", \$fDegrees, Int(\$fMinutes), \$fSeconds)
EndFunc```

Oops. Sorry, first one of the day. I get more frustrated as the day progresses so I am less willing to help @ 5:00. Edited by weaponx

Many thanks!

##### Share on other sites

Oops. Sorry, first one of the day. I get more frustrated as the day progresses so I am less willing to help @ 5:00.

Giving away fish in a caffeine-induced early morning frenzy...

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

## Create an account

Register a new account