35 static int nfuncs = sizeof funcs / sizeof *funcs;
47 static double tod(uint32_t *a) {
48 union { double x; uint64_t n; } u;
50 u.n = ((uint64_t)a[0] << 32) | a[1];
54 int scantest(struct test *t) {
63 if (!fgets(buf, sizeof buf, stdin))
66 if (sscanf(buf, "%30s %30s %30s %30s %x %x %x %x %x %x",
67 name, round, cmp, except, a+0, a+1, a+2, a+3, a+4, a+5) < 8)
70 for (i = 0; i < nfuncs; i++)
71 if (strcmp(funcs[i].name, name) == 0)
76 t->round = round[0] == 'n';
78 t->except = t->exceptopt = 0;
79 for (i = 0; i < sizeof except; i++) {
82 if (except[i] == '\0')
85 case 'v': f = FE_INVALID; break;
86 case 'x': f = FE_INEXACT; break;
87 case 'o': f = FE_OVERFLOW; break;
88 case 'u': f = FE_UNDERFLOW; break;
89 case 'd': f = FE_DIVBYZERO; break;
93 if (i > 0 && except[i-1]=='?')
101 if (t->func->args == 1) {
108 if (strcmp(cmp, "uo") == 0)
115 union {double x; uint64_t n;} got, want;
117 int n=0, err=0, err2=0, err99=0;
119 while (!feof(stdin)) {
121 // puts("scan fail");
126 if (t.func->args == 1)
127 got.x = t.func->f(t.in1);
129 got.x = t.func->f(t.in1, t.in2);
132 if (got.n != want.n &&
133 (!isnan(got.x) || !isnan(want.x))) {
135 // hack: mostly error in ulp
136 k = (int64_t)(got.n - want.n);
143 if (k == 99 || k == -99)
145 printf("%3d ulp %16llx %16llx %s %a %a %a %a\n",
146 (int)k, want.n, got.n, t.func->name, t.in1, t.in2, t.out, got.x);
150 printf("all: %d fail: %d failbad: %d failepic: %d\n", n, err, err2, err99);