Astro-PAL

 view release on metacpan or  search on metacpan

erfasrc/src/taiutc.c  view on Meta::CPAN

/* Put the two parts of the TAI into big-first order. */
   big1 = ( fabs(tai1) >= fabs(tai2) );
   if ( big1 ) {
      a1 = tai1;
      a2 = tai2;
   } else {
      a1 = tai2;
      a2 = tai1;
   }

/* Initial guess for UTC. */
   u1 = a1;
   u2 = a2;

/* Iterate (though in most cases just once is enough). */
   for ( i = 0; i < 3; i++ ) {

   /* Guessed UTC to TAI. */
      j = eraUtctai(u1, u2, &g1, &g2);
      if ( j < 0 ) return j;

   /* Adjust guessed UTC. */
      u2 += a1 - g1;
      u2 += a2 - g2;
   }

/* Return the UTC result, preserving the TAI order. */
   if ( big1 ) {
      *utc1 = u1;
      *utc2 = u2;
   } else {
      *utc1 = u2;



( run in 0.978 second using v1.01-cache-2.11-cpan-702932259ff )