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