fix ulp check in sincosf
[libc-test.git] / src / math / sincosf.c
blobf8df662ade19fb3369e5766f6e2b045a4f296908
1 #define _GNU_SOURCE 1
2 #include <stdint.h>
3 #include <stdio.h>
4 #include "mtest.h"
6 static struct f_ff t[] = {
7 #include "sanity/sincosf.h"
8 #include "special/sincosf.h"
9 };
11 int main(void)
13 #pragma STDC FENV_ACCESS ON
14 float ysin, ycos;
15 float dsin, dcos;
16 int e, i, err = 0;
17 struct f_ff *p;
19 for (i = 0; i < sizeof t/sizeof *t; i++) {
20 p = t + i;
22 if (p->r < 0)
23 continue;
24 fesetround(p->r);
25 feclearexcept(FE_ALL_EXCEPT);
26 sincosf(p->x, &ysin, &ycos);
27 e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
29 if (!checkexcept(e, p->e, p->r)) {
30 printf("%s:%d: bad fp exception: %s sincosf(%a)=%a,%a, want %s",
31 p->file, p->line, rstr(p->r), p->x, p->y, p->y2, estr(p->e));
32 printf(" got %s\n", estr(e));
33 err++;
35 dsin = ulperrf(ysin, p->y, p->dy);
36 dcos = ulperrf(ycos, p->y2, p->dy2);
37 if (!checkulp(dsin, p->r) || !checkulp(dcos, p->r)) {
38 printf("%s:%d: %s sincosf(%a) want %a,%a got %a,%a, ulperr %.3f = %a + %a, %.3f = %a + %a\n",
39 p->file, p->line, rstr(p->r), p->x, p->y, p->y2, ysin, ycos,
40 dsin, dsin-p->dy, p->dy, dcos, dcos-p->dy2, p->dy2);
41 err++;
44 return !!err;