source: trunk/MagicSoft/slalib/dd2tf.c@ 9472

Last change on this file since 9472 was 731, checked in by tbretz, 24 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 1.3 KB
Line 
1#include "slalib.h"
2#include "slamac.h"
3void slaDd2tf ( int ndp, double days, char *sign, int ihmsf[4] )
4/*
5** - - - - - - - - -
6** s l a D d 2 t f
7** - - - - - - - - -
8**
9** Convert an interval in days into hours, minutes, seconds.
10**
11** (double precision)
12**
13** Given:
14** ndp int number of decimal places of seconds
15** days double interval in days
16**
17** Returned:
18** *sign char '+' or '-'
19** ihmsf int[4] hours, minutes, seconds, fraction
20**
21** Last revision: 31 August 1995
22**
23** Copyright P.T.Wallace. All rights reserved.
24*/
25
26#define D2S 86400.0 /* Days to seconds */
27
28{
29 double rs, rm, rh, a, ah, am, as, af;
30
31/* Handle sign */
32 *sign = (char) ( ( days < 0.0 ) ? '-' : '+' );
33
34/* Field units in terms of least significant figure */
35 rs = pow ( 10.0, (double) gmax ( ndp, 0 ) );
36 rs = dint ( rs );
37 rm = rs * 60.0;
38 rh = rm * 60.0;
39
40/* Round interval and express in smallest units required */
41 a = rs * D2S * fabs ( days );
42 a = dnint ( a );
43
44/* Separate into fields */
45 ah = a / rh;
46 ah = dint ( ah );
47 a = a - ah * rh;
48 am = a / rm;
49 am = dint ( am );
50 a = a - am * rm;
51 as = a / rs;
52 as = dint ( as );
53 af = a - as * rs;
54
55/* Return results */
56 ihmsf[0] = (int) ah;
57 ihmsf[1] = (int) am;
58 ihmsf[2] = (int) as;
59 ihmsf[3] = (int) af;
60}
Note: See TracBrowser for help on using the repository browser.