taia — manipulate times with 1-attosecond precision
#include <taia.h> double \fBtaia_approx\fP(&\fIt\fR); double \fBtaia_frac\fP(&\fIt\fR); void \fBtaia_tai\fP(&\fIt\fR,&\fIsec\fR); int \fBtaia_less\fP(&\fIa\fR,&\fIb\fR); void \fBtaia_add\fP(&\fIt\fR,&\fIa\fR,&\fIb\fR); void \fBtaia_sub\fP(&\fIt\fR,&\fIa\fR,&\fIb\fR); void \fBtaia_half\fP(&\fIt\fR,&\fIa\fR); unsigned int \fBtaia_fmtfrac\fP(\fIs\fR,&\fIt\fR); struct taia \fIt\fR; struct taia \fIa\fR; struct taia \fIb\fR; struct tai \fIsec\fR; char *\fIs\fR;
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.
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.