8d1e07599ed08851907b2af50740edd061ad232f
[libc-test] / src / math / sincosl.c
1 #include <stdint.h>
2 #include <stdio.h>
3 #include "mtest.h"
4
5 static struct l_ll t[] = {
6 #if LDBL_MANT_DIG == 53
7 #include "sanity/sincos.h"
8 #include "special/sincos.h"
9 #elif LDBL_MANT_DIG == 64
10 #include "sanity/sincosl.h"
11 #include "special/sincosl.h"
12 #endif
13 };
14
15 int main(void)
16 {
17         #pragma STDC FENV_ACCESS ON
18         long double ysin, ycos;
19         float dsin, dcos;
20         int e, i, err = 0;
21         struct l_ll *p;
22
23         for (i = 0; i < sizeof t/sizeof *t; i++) {
24                 p = t + i;
25
26                 if (p->r < 0)
27                         continue;
28                 fesetround(p->r);
29                 feclearexcept(FE_ALL_EXCEPT);
30                 sincosl(p->x, &ysin, &ycos);
31                 e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
32
33                 if (!checkexcept(e, p->e, p->r)) {
34                         printf("%s:%d: bad fp exception: %s sincosl(%La)=%La,%La, want %s",
35                                 p->file, p->line, rstr(p->r), p->x, p->y, p->y2, estr(p->e));
36                         printf(" got %s\n", estr(e));
37                         err++;
38                 }
39                 dsin = ulperr(ysin, p->y, p->dy);
40                 dcos = ulperr(ycos, p->y2, p->dy2);
41                 if (!checkulp(dsin, p->r) || !checkulp(dcos, p->r)) {
42                         printf("%s:%d: %s sincosl(%La) want %La,%La got %La,%La, ulperr %.3f = %a + %a, %.3f = %a + %a\n",
43                                 p->file, p->line, rstr(p->r), p->x, p->y, p->y2, ysin, ycos,
44                                 dsin, dsin-p->dy, p->dy, dcos, dcos-p->dy2, p->dy2);
45                         err++;
46                 }
47         }
48         return !!err;
49 }