|
nsz |
21dd45 |
#include <stdint.h>
|
|
nsz |
21dd45 |
#include <stdio.h>
|
|
nsz |
21dd45 |
#include "util.h"
|
|
nsz |
21dd45 |
|
|
nsz |
21dd45 |
static struct di_d t[] = {
|
|
nsz |
21dd45 |
#include "sanity/jn.h"
|
|
Szabolcs Nagy |
f3f0ff |
#include "special/jn.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 di_d *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 = jn(p->i, p->x);
|
|
nsz |
21dd45 |
e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
|
|
nsz |
21dd45 |
|
|
nsz |
21dd45 |
if (!checkexcept(e, p->e, p->r)) {
|
|
nsz |
21dd45 |
printf("%s:%d: bad fp exception: %s jn(%a, %lld)=%a, want %s",
|
|
nsz |
21dd45 |
p->file, p->line, rstr(p->r), p->x, p->i, p->y, estr(p->e));
|
|
nsz |
21dd45 |
printf(" got %s\n", estr(e));
|
|
nsz |
21dd45 |
err++;
|
|
nsz |
21dd45 |
}
|
|
nsz |
21dd45 |
d = ulperr(y, p->y, p->dy);
|
|
nsz |
21dd45 |
if (!checkulp(d, p->r)) {
|
|
nsz |
21dd45 |
printf("%s:%d: %s jn(%a, %lld) want %a got %a, ulperr %.3f = %a + %a\n",
|
|
nsz |
21dd45 |
p->file, p->line, rstr(p->r), p->x, p->i, p->y, y, d, d-p->dy, p->dy);
|
|
nsz |
21dd45 |
err++;
|
|
nsz |
21dd45 |
}
|
|
nsz |
21dd45 |
}
|
|
nsz |
21dd45 |
return !!err;
|
|
nsz |
21dd45 |
}
|