b03cc74d9d6855aa0b60636318e2e32be1fbb7b4
[libc-test] / src / math / erfl.c
1 #include <stdint.h>
2 #include <stdio.h>
3 #include "util.h"
4
5 static struct l_l t[] = {
6 #if LDBL_MANT_DIG == 53
7 #include "sanity/erf.h"
8
9 #elif LDBL_MANT_DIG == 64
10 #include "sanity/erfl.h"
11
12 #endif
13 };
14
15 int main(void)
16 {
17         long double y;
18         float d;
19         int e, i, err = 0;
20         struct l_l *p;
21
22         for (i = 0; i < sizeof t/sizeof *t; i++) {
23                 p = t + i;
24                 setupfenv(p->r);
25                 y = erfl(p->x);
26                 e = getexcept();
27                 if (!checkexcept(e, p->e, p->r)) {
28                         printf("%s:%d: bad fp exception: %s erfl(%La)=%La, want %s",
29                                 p->file, p->line, rstr(p->r), p->x, p->y, estr(p->e));
30                         printf(" got %s\n", estr(e));
31                         err++;
32                 }
33                 d = ulperrl(y, p->y, p->dy);
34                 if (!checkulp(d, p->r)) {
35                         printf("%s:%d: %s erfl(%La) want %La got %La ulperr %.3f = %a + %a\n",
36                                 p->file, p->line, rstr(p->r), p->x, p->y, y, d, d-p->dy, p->dy);
37                         err++;
38                 }
39         }
40         return !!err;
41 }