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 posneg}\times {\rm DEd})\times 60.0\times {\rm posneg})$$

$${\rm DEs} = ({\rm DecDE} - {\rm posneg}\times {\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 - (-1.0)\times 45)\times 60.0\times (-1.0)) = 40$$

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