|
Szabolcs Nagy |
2c671f |
#define _DEFAULT_SOURCE 1
|
|
Szabolcs Nagy |
7b5ccd |
#define _BSD_SOURCE 1
|
|
nsz |
21dd45 |
#include <stdint.h>
|
|
nsz |
21dd45 |
#include <stdio.h>
|
|
Szabolcs Nagy |
cfa23c |
#include "mtest.h"
|
|
nsz |
21dd45 |
|
|
nsz |
21dd45 |
static struct fi_f t[] = {
|
|
nsz |
21dd45 |
#include "sanity/jnf.h"
|
|
Szabolcs Nagy |
f3f0ff |
#include "special/jnf.h"
|
|
nsz |
21dd45 |
};
|
|
nsz |
21dd45 |
|
|
nsz |
21dd45 |
int main(void)
|
|
nsz |
21dd45 |
{
|
|
nsz |
21dd45 |
#pragma STDC FENV_ACCESS ON
|
|
nsz |
21dd45 |
double y;
|
|
nsz |
21dd45 |
float d;
|
|
nsz |
21dd45 |
int e, i, err = 0;
|
|
nsz |
21dd45 |
struct fi_f *p;
|
|
nsz |
21dd45 |
|
|
nsz |
21dd45 |
for (i = 0; i < sizeof t/sizeof *t; i++) {
|
|
nsz |
21dd45 |
p = t + i;
|
|
nsz |
21dd45 |
|
|
nsz |
21dd45 |
if (p->r < 0)
|
|
nsz |
21dd45 |
continue;
|
|
nsz |
21dd45 |
fesetround(p->r);
|
|
nsz |
21dd45 |
feclearexcept(FE_ALL_EXCEPT);
|
|
nsz |
21dd45 |
y = jnf(p->i, p->x);
|
|
nsz |
21dd45 |
e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
|
|
nsz |
21dd45 |
|
|
nsz |
21dd45 |
if (!checkexcept(e, p->e, p->r)) {
|
|
Szabolcs Nagy |
d19c6f |
printf("%s:%d: bad fp exception: %s jnf(%lld, %a)=%a, want %s",
|
|
Szabolcs Nagy |
d19c6f |
p->file, p->line, rstr(p->r), p->i, p->x, p->y, estr(p->e));
|
|
nsz |
21dd45 |
printf(" got %s\n", estr(e));
|
|
nsz |
21dd45 |
err++;
|
|
nsz |
21dd45 |
}
|
|
nsz |
21dd45 |
d = ulperrf(y, p->y, p->dy);
|
|
nsz |
21dd45 |
if (!checkulp(d, p->r)) {
|
|
Szabolcs Nagy |
5fc943 |
if (fabsf(d) < 3.0f)
|
|
Szabolcs Nagy |
5fc943 |
printf("X ");
|
|
Szabolcs Nagy |
5fc943 |
else
|
|
Szabolcs Nagy |
5fc943 |
err++;
|
|
Szabolcs Nagy |
d19c6f |
printf("%s:%d: %s jnf(%lld, %a) want %a got %a, ulperr %.3f = %a + %a\n",
|
|
Szabolcs Nagy |
d19c6f |
p->file, p->line, rstr(p->r), p->i, p->x, p->y, y, d, d-p->dy, p->dy);
|
|
nsz |
21dd45 |
}
|
|
nsz |
21dd45 |
}
|
|
nsz |
21dd45 |
return !!err;
|
|
nsz |
21dd45 |
}
|