taia(3)                                                   taia(3)



NAME
       taia - manipulate times with 1-attosecond precision

SYNTAX
       #include <taia.h>

       double taia_approx(&_t);
       double taia_frac(&_t);
       void taia_tai(&_t,&sec);

       int taia_less(&_a,&_b);
       void taia_add(&_t,&_a,&_b);
       void taia_sub(&_t,&_a,&_b);
       void taia_half(&_t,&_a);

       unsigned int taia_fmtfrac(_s,&_t);

       struct taia _t;
       struct taia _a;
       struct taia _b;
       struct tai sec;
       char *_s;

DESCRIPTION
       A  struct  taia  stores an integer between 0 inclusive and
       2^64x10^18  exclusive.   The  format  of  struct  taia  is
       designed  to  speed  up  common  operations;  applications
       should not look inside struct taia.

       A struct taia variable is commonly used to store a TAI64NA
       label.   Each  TAI64NA  label  refers to one attosecond of
       real time; see  http://pobox.com/~djb/proto/tai64.txt  for
       more information.  The integer in the struct taia is 10^18
       times the second count, plus  10^9  times  the  nanosecond
       count, plus the attosecond count.

       A  struct  taia  variable  may  also  be used to store the
       numerical difference between two TAI64NA labels.

ARITHMETIC
       taia_approx returns a  double-precision  approximation  to
       _t/10^18.  The result of taia_approx is always nonnegative.

       taia_tai places into sec the integer part of _t/10^18.

       taia_frac returns a double-precision approximation to  the
       fraction  part  of  _t/10^18.   The  result of taia_frac is
       always nonnegative.

       taia_less returns 1 if _a is smaller than _b, 0 otherwise.

       taia_add adds _a and  _b  modulo  2^64x10^18  and  puts  the
       result into _t.  The inputs and outputs may overlap.

       taia_sub subtracts _b from _a modulo 2^64x10^18 and puts the
       result into _t.  The inputs and outputs may overlap.

       taia_half divides _a by 2,  rounding  down,  and  puts  the
       result into _t.  The input and output may overlap.

FORMATTING
       taia_fmtfrac  prints  the  remainder of _t/10^18, padded to
       exactly 18 digits, into the character buffer _s, without  a
       terminating  NUL.  It returns 18, the number of characters
       written.  _s may be  zero;  then  taia_fmtfrac  returns  18
       without printing anything.

       The  macro  TAIA_FMTFRAC  is defined as 19; this is enough
       space for the output of  taia_fmtfrac  and  a  terminating
       NUL.

SEE ALSO
       taia_now(3), taia_pack(3), tai(3)



                                                          taia(3)
