# Convert decimal degrees to d,m,s

## Recommended Posts

Does anyone have a formula to convert decimal degrees to degrees, minutes & seconds?  I need to do this in a user macro.

##### Share on other sites

I use a calculator, but I found this explanation with Google:

The whole units of degrees will remain the same (e.g., if your figure is 121.135 degrees longitude, start with 121 degrees).

Multiply the decimal portion of the figure by 60 (e.g., .135 * 60 = 8.1).

The whole number becomes the minutes (8).

Take the remaining decimal and multiply it by 60 (e.g., .1 * 60 = 6).

The resulting number becomes the seconds (6 seconds). Seconds can remain as a decimal if needed.

Take your three sets of numbers and put them together, (e.g., 121°8'6" longitude would be equivalent to 121.135 degrees longitude).

##### Share on other sites

Thanks Robert.

I found the same on the internet.  Unfortunately I don't seem to be able to get it to work correctly in a user macro.  I guess for now I'm just going to have to display decimal degrees.

##### Share on other sites

result=""

fl = 121.135

d= fl.to_i

m=(fl-d) * 60.0

s =( m - m.to_i) * 60.0

result = d.to_s + " " + m.to_i.to_s + " " + s.to_i.to_s

result

##### Share on other sites

I got it to work.  One of my problems was that I wanted it to be in the form of:

N d m s W

etc.  Basically getting the wall facing direction by comparing the true north of the plan with the angle of the exterior walls.  Since the wall angle is 0 to 360 I had to do some tricky coding.