Astronomers use right ascension (RA) and declination (Dec) to refer to the sky coordinates of celestial objects. RA and Dec can take be represented degrees or in sexagesimal (base 60). How can I convert from sexagesimal to degrees while keeping the correct amount of significant figures? That is easy if we use scientific notation, but what if I want to represent +2.33750 as it is, not as 2.3375?

  • 2
    $\begingroup$ FromDMS[] is built-in: FromDMS[{2, 20, 15.}]. Use NumberForm[] if need be. $\endgroup$ Commented Nov 14, 2017 at 7:51
  • 1
    $\begingroup$ The longer and slower version would be UnitConvert[Quantity[MixedMagnitude[{2, 20, 15.}], MixedUnit[{"AngularDegrees", "ArcMinutes", "ArcSeconds"}]], "AngularDegrees"]. $\endgroup$ Commented Nov 14, 2017 at 7:55

1 Answer 1


First of all, note that RA (right ascension) is hr:min:sec. while Dec (declination) is deg:min:sec.. I have written the following function which lets you pick how the number of digits to the right of your output using PaddedForm:

SexagesimalToDegree[{hrORdeg_, min_, sec_}, 
  coord_ /; (coord == "RA" ∨ coord == "Dec"), numRHSdigits_: 6] :=

  coord == "RA", 
  PaddedForm[(1/1 hrORdeg + 1/60 min + 1 /3600 sec) 360./
    24., {Infinity, numRHSdigits}, NumberPadding -> {"", "0"}, 
   NumberSigns -> {"-", "+"}],

  coord == "Dec", 
  PaddedForm[(1/1 hrORdeg + 1/60 min + 1 /3600 sec) 1./1., {Infinity, 
    numRHSdigits}, NumberPadding -> {"", "0"}, 
   NumberSigns -> {"-", "+"}]

For example, let's say you want to convert declination of 02:20:15.69 to degrees keeping 5 decimals to the right of your output since you want to be sensitive to 0.1 arcsec which is 0.000028 deg.

SexagesimalToDegree[{+02, 20, 15.0}, "Dec", 5]

which gives you


But keep in mind as soon as you do any manipulation on this output, the NumberFormat/PaddedForm will change.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.