# Convert a Decimal into RA or Dec

http://exoplanets.eu/ displays R.A. on screen in hh:mm:ss format but when you export the table, it gives the R.A. as a decimal. Likewise for Declination.

How can I turn for example 24.35417 (WASP-18) into 01:37:25.0 ? And likewise for Declination -45.67778 to -45:40:40? I'm looking for a method, not a website that will do it for me.

Either a way to convert between formats or how do I export in non-decimal format?

Thanks

DecRA is the decimal right ascension RAh, RAm, RAs are the hms form

$${\rm DecRA} = {\rm RAh}\times 15.0 + {\rm RAm}/4.0 + {\rm RAs}/240.0$$

$${\rm RAh} = {\rm INT}({\rm DecRA}/15.0)$$

$${\rm RAm} = {\rm INT}(({\rm DecRA}-{\rm RAh}\times 15.0)\times 4.0)$$

$${\rm RAs} = ({\rm DecRA}-{\rm Rah}\times 15.0 - {\rm RAm}/4.0)\times 240.0$$

where INT is the operation that truncates to an integer

e.g. DecRA=24.35417

$${\rm RAh} = {\rm INT}(24.35417/15.0) = 1$$

$${\rm RAm} = {\rm INT}((24.35417 - 1\times 15.0)\times 4.0) = 37$$

$${\rm RAs} = (24.35417-1\times 15.0 - 37/4.0)\times 240.0 = 25.00$$

DecDE is the decimal declination

DEd, DEm, DEs are the dms form

posneg is -1.0 for a position below the celestial equator (negative declination) and +1.0 for above the equator

$${\rm DecDE} = {\rm DEd} + {\rm posneg}\times {\rm DEm}/60.0 + {\rm posneg}\times {\rm DEs}/3600.0$$

$${\rm DEd} = {\rm INT}({\rm DecDE})$$

$${\rm DEm} = {\rm INT}(({\rm DecDE} - {\rm DEd})\times 60.0\times {\rm posneg})$$

$${\rm DEs} = ({\rm DecDE} - {\rm DEd} - {\rm posneg}\times {\rm DEm}/60.0)\times 3600.0\times {\rm posneg}$$

e.g. DecDE = -45.67778 posneg=-1.0

$${\rm DEd} = {\rm INT}(-45.67778) = -45$$

$${\rm DEm} = {\rm INT}((-45.67778 - (-45))\times 60.0\times (-1.0)) = 40$$

$${\rm DEs} = (-45.67778 - (-45) - (-1.0)\times 40/60.0)\times 3600\times (-1.0) = 40.0$$

• Just to clarify does PosNeg relate to the Observer, so as we're in the UK, that'll be 1.0 and if in Australia, -1? or does PosNeg mean if the Dec is a positive number then 1.0 otherwise -1? Jan 13, 2018 at 19:00
• @MiscellaneousUser It applies to the source position. Jan 14, 2018 at 0:51
• if your dec degrees are never negative try : (DEd + DEm/60.0 + DEs/3600.0)*posneg
– tomc
Aug 7, 2021 at 22:41
• In the line DEm, should DEd be the absolute of DEd ? Therefore the formula would be DEm = INT((-45.67778-(-1.0)*abs(DEd)x60x(-1)? I can't see how you get x 40 otherwise. Feb 21, 2022 at 20:09
• @MiscellaneousUser I think I've got it. A spurious posneg. Feb 21, 2022 at 20:57