0bad58550904edbac8d0c39ef2deca5cbfdcae15
[libc-test] / src / math / powf.c
1 #include <stdint.h>
2 #include <stdio.h>
3 #include "util.h"
4
5 static struct ff_f t[] = {
6
7 #include "ucb/powf.h"
8 #include "sanity/powf.h"
9 };
10
11 int main(void)
12 {
13         float y;
14         float d;
15         int e, i, err = 0;
16         struct ff_f *p;
17
18         for (i = 0; i < sizeof t/sizeof *t; i++) {
19                 p = t + i;
20                 setupfenv(p->r);
21                 y = powf(p->x, p->x2);
22                 e = getexcept();
23                 if (!checkexcept(e, p->e, p->r)) {
24                         printf("%s powf(%a,%a)==%a except: want %s", rstr(p->r), p->x, p->x2, p->y, estr(p->e));
25                         printf(" got %s\n", estr(e));
26                         err++;
27                 }
28                 d = ulperrf(y, p->y, p->dy);
29                 if (!checkulp(d, p->r)) {
30                         printf("%s powf(%a,%a) want %a got %a ulperr %.3f = %a + %a\n",
31                                 rstr(p->r), p->x, p->x2, p->y, y, d, d-p->dy, p->dy);
32                         err++;
33                 }
34         }
35         return !!err;
36 }