suitcase

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

taia_sub.c (434B)


      1 #include <tai/taia.h>
      2 
      3 /* XXX: breaks tai encapsulation */
      4 
      5 void taia_sub(struct taia *t, struct taia *u, struct taia *v)
      6 {
      7   unsigned long unano = u->nano;
      8   unsigned long uatto = u->atto;
      9   
     10   t->sec.x = u->sec.x - v->sec.x;
     11   t->nano = unano - v->nano;
     12   t->atto = uatto - v->atto;
     13   if (t->atto > uatto) {
     14     t->atto += 1000000000UL;
     15     --t->nano;
     16   }
     17   if (t->nano > unano) {
     18     t->nano += 1000000000UL;
     19     --t->sec.x;
     20   }
     21 }