|
nsz |
cb9f87 |
#include <stdint.h>
|
|
nsz |
cb9f87 |
#include <stdio.h>
|
|
Szabolcs Nagy |
cfa23c |
#include "mtest.h"
|
|
nsz |
cb9f87 |
|
|
nsz |
cb9f87 |
static struct l_ll t[] = {
|
|
nsz |
cb9f87 |
#if LDBL_MANT_DIG == 53
|
|
nsz |
cb9f87 |
#include "sanity/modf.h"
|
|
Szabolcs Nagy |
f3f0ff |
#include "special/modf.h"
|
|
nsz |
cb9f87 |
#elif LDBL_MANT_DIG == 64
|
|
nsz |
cb9f87 |
#include "sanity/modfl.h"
|
|
Szabolcs Nagy |
f3f0ff |
#include "special/modfl.h"
|
|
nsz |
cb9f87 |
#endif
|
|
nsz |
cb9f87 |
};
|
|
nsz |
cb9f87 |
|
|
nsz |
cb9f87 |
int main(void)
|
|
nsz |
cb9f87 |
{
|
|
nsz |
cb9f87 |
#pragma STDC FENV_ACCESS ON
|
|
nsz |
cb9f87 |
long double y, yi;
|
|
nsz |
cb9f87 |
float d, di;
|
|
nsz |
cb9f87 |
int e, i, err = 0;
|
|
nsz |
cb9f87 |
struct l_ll *p;
|
|
nsz |
cb9f87 |
|
|
nsz |
cb9f87 |
for (i = 0; i < sizeof t/sizeof *t; i++) {
|
|
nsz |
cb9f87 |
p = t + i;
|
|
nsz |
cb9f87 |
|
|
nsz |
cb9f87 |
if (p->r < 0)
|
|
nsz |
cb9f87 |
continue;
|
|
nsz |
cb9f87 |
fesetround(p->r);
|
|
nsz |
cb9f87 |
feclearexcept(FE_ALL_EXCEPT);
|
|
nsz |
cb9f87 |
y = modfl(p->x, &yi);
|
|
nsz |
cb9f87 |
e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
|
|
nsz |
cb9f87 |
|
|
nsz |
cb9f87 |
if (!checkexcept(e, p->e, p->r)) {
|
|
nsz |
cb9f87 |
printf("%s:%d: bad fp exception: %s modf(%La)=%La,%La, want %s",
|
|
nsz |
cb9f87 |
p->file, p->line, rstr(p->r), p->x, p->y, p->y2, estr(p->e));
|
|
nsz |
cb9f87 |
printf(" got %s\n", estr(e));
|
|
nsz |
cb9f87 |
err++;
|
|
nsz |
cb9f87 |
}
|
|
nsz |
cb9f87 |
d = ulperr(y, p->y, p->dy);
|
|
nsz |
cb9f87 |
di = ulperr(yi, p->y2, p->dy2);
|
|
Szabolcs Nagy |
9c6efc |
if (!checkcr(y, p->y, p->r) || !checkcr(yi, p->y2, p->r)) {
|
|
nsz |
cb9f87 |
printf("%s:%d: %s modf(%La) want %La,%La got %La,%La, ulperr %.3f = %a + %a, %.3f = %a + %a\n",
|
|
nsz |
cb9f87 |
p->file, p->line, rstr(p->r), p->x, p->y, p->y2, y, yi, d, d-p->dy, p->dy, di, di-p->dy2, p->dy2);
|
|
nsz |
cb9f87 |
err++;
|
|
nsz |
cb9f87 |
}
|
|
nsz |
cb9f87 |
}
|
|
nsz |
cb9f87 |
return !!err;
|
|
nsz |
cb9f87 |
}
|