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