<p>DecRA is the decimal right ascension
RAh, RAm, RAs are the hms form</p>
<hr />
<p><span class="math-container">$${\rm DecRA} = {\rm RAh}\times 15.0 + {\rm RAm}/4.0 + {\rm RAs}/240.0$$</span></p>
<p><span class="math-container">$$ {\rm RAh} = {\rm INT}({\rm DecRA}/15.0) $$</span></p>
<p><span class="math-container">$${\rm RAm} = {\rm INT}(({\rm DecRA}-{\rm RAh}\times 15.0)\times 4.0)$$</span></p>
<p><span class="math-container">$${\rm RAs} = ({\rm DecRA}-{\rm Rah}\times 15.0 - {\rm RAm}/4.0)\times 240.0$$</span></p>
<p>where INT is the operation that <em>truncates</em> to an integer</p>
<hr />
<p>e.g. DecRA=24.35417</p>
<p><span class="math-container">$${\rm RAh} = {\rm INT}(24.35417/15.0) = 1$$</span></p>
<p><span class="math-container">$${\rm RAm} = {\rm INT}((24.35417 - 1\times 15.0)\times 4.0) = 37$$</span></p>
<p><span class="math-container">$${\rm RAs} = (24.35417-1\times 15.0 - 37/4.0)\times 240.0 = 25.00$$</span></p>
<p>DecDE is the decimal declination</p>
<p>DEd, DEm, DEs are the dms form</p>
<p>posneg is -1.0 for a position below the celestial equator (negative declination) and +1.0 for above the equator</p>
<hr />
<p><span class="math-container">$${\rm DecDE} = {\rm DEd} + {\rm posneg}\times {\rm DEm}/60.0 + {\rm posneg}\times {\rm DEs}/3600.0$$</span></p>
<p><span class="math-container">$${\rm DEd} = {\rm INT}({\rm DecDE})$$</span></p>
<p><span class="math-container">$${\rm DEm} = {\rm INT}(({\rm DecDE} - {\rm DEd})\times 60.0\times {\rm posneg})$$</span></p>
<p><span class="math-container">$${\rm DEs} = ({\rm DecDE} - {\rm DEd} - {\rm posneg}\times {\rm DEm}/60.0)\times 3600.0\times {\rm posneg}$$</span></p>
<hr />
<p>e.g. DecDE = -45.67778   posneg=-1.0</p>
<p><span class="math-container">$${\rm DEd} = {\rm INT}(-45.67778) = -45$$</span></p>
<p><span class="math-container">$${\rm DEm} = {\rm INT}((-45.67778 - (-45))\times 60.0\times (-1.0)) = 40$$</span></p>
<p><span class="math-container">$${\rm DEs} = (-45.67778 - (-45) - (-1.0)\times 40/60.0)\times 3600\times (-1.0) = 40.0$$</span></p>

CC BY-SA 3.0
2018-01-13T19:00:01.457Z
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?
MiscellaneousUser
CC BY-SA 3.0
2018-01-14T00:51:09.607Z
@MiscellaneousUser It applies to the source position.
ProfRob
CC BY-SA 4.0
2021-08-07T22:41:43.180Z
if your dec degrees  are never negative  try : (DEd + DEm/60.0 + DEs/3600.0)*posneg
tomc
CC BY-SA 4.0
2022-02-21T20:09:56.307Z
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.
MiscellaneousUser
CC BY-SA 4.0
2022-02-21T20:57:40.443Z
@MiscellaneousUser I think I've got it. A spurious posneg.
ProfRob
CC BY-SA 4.0
2018-01-13T17:23:55.500Z
2022-02-21T20:56:57.090Z
2022-02-21T20:56:57.090Z
ProfRob
<p><a href="http://exoplanets.eu/" rel="nofollow noreferrer">http://exoplanets.eu/</a> 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.  </p>

<p>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.</p>

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

<p>Thanks</p>

CC BY-SA 4.0
2022-02-22T05:40:21.833Z
ProfRob's answer below is correct, but here is an actual implementation in Javascript that might help eliminate ambiguity. https://www.celestialprogramming.com/decimal_degrees_to_components.html
Greg Miller
<star><declination><right-ascension>
Convert a Decimal into RA or Dec
MiscellaneousUser
# Convert a Decimal into RA or Dec

(Asked by: username_0 on 2018-01-13)

<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

**Tags:** star, declination, right-ascension

> **Comments:**
> **username_1**: username_2's answer below is correct, but here is an actual implementation in Javascript that might help eliminate ambiguity. https://www.celestialprogramming.com/decimal_degrees_to_components.html  

---

## 1 answers

### Answer by username_2 on 2018-01-13. Score: 4 | Accepted answer

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$$

> **Comments:**
> **username_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?  
> **username_2**: @username_0 It applies to the source position.  
> **username_3**: if your dec degrees  are never negative  try : (DEd + DEm/60.0 + DEs/3600.0)*posneg  
> **username_0**: 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.  
> **username_2**: @username_0 I think I've got it. A spurious posneg.  

---

