math: add jn and yn
[libc-test] / src / math / yn.c
1 #include <stdint.h>
2 #include <stdio.h>
3 #include "util.h"
4
5 static struct di_d t[] = {
6 #include "sanity/yn.h"
7 };
8
9 int main(void)
10 {
11         #pragma STDC FENV_ACCESS ON
12         double y;
13         float d;
14         int e, i, err = 0;
15         struct di_d *p;
16
17         for (i = 0; i < sizeof t/sizeof *t; i++) {
18                 p = t + i;
19
20                 if (p->r < 0)
21                         continue;
22                 fesetround(p->r);
23                 feclearexcept(FE_ALL_EXCEPT);
24                 y = yn(p->i, p->x);
25                 e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
26
27                 if (!checkexcept(e, p->e, p->r)) {
28                         printf("%s:%d: bad fp exception: %s yn(%a, %lld)=%a, want %s",
29                                 p->file, p->line, rstr(p->r), p->x, p->i, p->y, estr(p->e));
30                         printf(" got %s\n", estr(e));
31                         err++;
32                 }
33                 d = ulperr(y, p->y, p->dy);
34                 if (!checkulp(d, p->r)) {
35                         printf("%s:%d: %s yn(%a, %lld) want %a got %a, ulperr %.3f = %a + %a\n",
36                                 p->file, p->line, rstr(p->r), p->x, p->i, p->y, y, d, d-p->dy, p->dy);
37                         err++;
38                 }
39         }
40         return !!err;
41 }