1 #include <stdint.h>
2 #include <stdio.h>
3 #include "util.h"
4
5 static struct ff_f t[] = {
6 HEADERS
7 };
8
main(void)9 int main(void)
10 {
11 #pragma STDC FENV_ACCESS ON
12 float y;
13 float d;
14 int e, i, err = 0;
15 struct ff_f *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 = ___(p->x, p->x2);
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 ___(%a,%a)=%a, want %s",
29 p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e));
30 printf(" got %s\n", estr(e));
31 err++;
32 }
33 d = ulperrf(y, p->y, p->dy);
34 if (!checkulp(d, p->r)) {
35 printf("%s:%d: %s ___(%a,%a) want %a got %a ulperr %.3f = %a + %a\n",
36 p->file, p->line, rstr(p->r), p->x, p->x2, p->y, y, d, d-p->dy, p->dy);
37 err++;
38 }
39 }
40 return !!err;
41 }
42