FACT++  1.0
void eraD2tf ( int  ndp,
double  days,
char *  sign,
int  ihmsf[4] 
)

Definition at line 3 of file d2tf.c.

References ERFA_DAYSEC, ERFA_DINT, and ERFA_DNINT.

Referenced by eraA2af(), eraA2tf(), eraD2dtf(), palDd2tf(), and t_d2tf().

54 {
55  int nrs, n;
56  double rs, rm, rh, a, w, ah, am, as, af;
57 
58 /* Handle sign. */
59  *sign = (char) ( ( days >= 0.0 ) ? '+' : '-' );
60 
61 /* Interval in seconds. */
62  a = ERFA_DAYSEC * fabs(days);
63 
64 /* Pre-round if resolution coarser than 1s (then pretend ndp=1). */
65  if (ndp < 0) {
66  nrs = 1;
67  for (n = 1; n <= -ndp; n++) {
68  nrs *= (n == 2 || n == 4) ? 6 : 10;
69  }
70  rs = (double) nrs;
71  w = a / rs;
72  a = rs * ERFA_DNINT(w);
73  }
74 
75 /* Express the unit of each field in resolution units. */
76  nrs = 1;
77  for (n = 1; n <= ndp; n++) {
78  nrs *= 10;
79  }
80  rs = (double) nrs;
81  rm = rs * 60.0;
82  rh = rm * 60.0;
83 
84 /* Round the interval and express in resolution units. */
85  a = ERFA_DNINT(rs * a);
86 
87 /* Break into fields. */
88  ah = a / rh;
89  ah = ERFA_DINT(ah);
90  a -= ah * rh;
91  am = a / rm;
92  am = ERFA_DINT(am);
93  a -= am * rm;
94  as = a / rs;
95  as = ERFA_DINT(as);
96  af = a - as * rs;
97 
98 /* Return results. */
99  ihmsf[0] = (int) ah;
100  ihmsf[1] = (int) am;
101  ihmsf[2] = (int) as;
102  ihmsf[3] = (int) af;
103 
104  return;
105 
106 }
#define ERFA_DINT(A)
Definition: erfam.h:125
#define ERFA_DAYSEC
Definition: erfam.h:75
#define ERFA_DNINT(A)
Definition: erfam.h:128

+ Here is the caller graph for this function: