functional: add mntent test
[libc-test.git] / src / math / frexpl.c
bloba0cb1b80b06797b695aa3755e10b86c922bfa54a
1 #include <stdint.h>
2 #include <stdio.h>
3 #include "mtest.h"
5 static struct l_li t[] = {
6 #if LDBL_MANT_DIG == 53
7 #include "sanity/frexp.h"
8 #include "special/frexp.h"
10 #elif LDBL_MANT_DIG == 64
11 #include "sanity/frexpl.h"
12 #include "special/frexpl.h"
14 #endif
17 int main(void)
19 #pragma STDC FENV_ACCESS ON
20 int yi;
21 long double y;
22 float d;
23 int e, i, err = 0;
24 struct l_li *p;
26 for (i = 0; i < sizeof t/sizeof *t; i++) {
27 p = t + i;
29 if (p->r < 0)
30 continue;
31 fesetround(p->r);
32 feclearexcept(FE_ALL_EXCEPT);
33 y = frexpl(p->x, &yi);
34 e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
36 if (!checkexceptall(e, p->e, p->r)) {
37 printf("%s:%d: bad fp exception: %s frexpl(%La)=%La,%lld, want %s",
38 p->file, p->line, rstr(p->r), p->x, p->y, p->i, estr(p->e));
39 printf(" got %s\n", estr(e));
40 err++;
42 d = ulperrl(y, p->y, p->dy);
43 if (!checkcr(y, p->y, p->r) || (isfinite(p->x) && yi != p->i)) {
44 printf("%s:%d: %s frexpl(%La) want %La,%lld got %La,%d ulperr %.3f = %a + %a\n",
45 p->file, p->line, rstr(p->r), p->x, p->y, p->i, y, yi, d, d-p->dy, p->dy);
46 err++;
49 return !!err;