# Working with degrees minutes and seconds without conversion

Is there a way to work with angles in DMS without converting them to decimal degrees, that is to sum them, subtract them?

I do not know how to even enter it without using string. My idea is something like: 20°32'15.828'' - 22°32'12.8''.

You may use either MixedRadixQuantity or Quantity with MixedMagnitude and MixedUnit.

In both cases the units you need are {"AngularDegrees", "ArcMinutes", "ArcSeconds"}.

p1 = MixedRadixQuantity[{20, 32, 15.828}, {"AngularDegrees", "ArcMinutes", "ArcSeconds"}];
p2 = MixedRadixQuantity[{22, 32, 12.8}, {"AngularDegrees", "ArcMinutes", "ArcSeconds"}];

p1 - p2
(* Quantity[MixedMagnitude[{-1, -59, -56.972}],
MixedUnit[{"AngularDegrees", "ArcMinutes", "ArcSeconds"}]] *)


From the output above you can see the longer form using Quantity.

Hope this helps.

• OK, I guess +1 for technical correctness, but...OMG...it's worse than COBOL. :) – Michael E2 Aug 27 '16 at 23:04
• @MichaelE2 Of course a helper function can be used: dms=MixedRadixQuantity[#, {"AngularDegrees", "ArcMinutes", "ArcSeconds"}]& – Edmund Aug 27 '16 at 23:14
• I suppose it's clear that I'm complaining about M, not your answer. I think carrying around these large, slow data structures internally is a waste. It's ok for UI purposes, although in this case, the formatted output is not highly readable. – Michael E2 Aug 27 '16 at 23:23