|
nsz |
ddfb9f |
#include <stdint.h>
|
|
nsz |
ddfb9f |
#include <stdio.h>
|
|
Szabolcs Nagy |
cfa23c |
#include "mtest.h"
|
|
nsz |
ddfb9f |
|
|
Szabolcs Nagy |
f3f0ff |
// TODO: separate ldbl dir
|
|
nsz |
ddfb9f |
static struct ll_l t[] = {
|
|
nsz |
ddfb9f |
#if LDBL_MANT_DIG == 53
|
|
nsz |
ddfb9f |
#include "sanity/nexttowardf.h"
|
|
Szabolcs Nagy |
f3f0ff |
#include "special/nexttowardf.h"
|
|
nsz |
ddfb9f |
|
|
nsz |
ddfb9f |
#elif LDBL_MANT_DIG == 64
|
|
nsz |
ddfb9f |
#include "sanity/nexttowardf.h"
|
|
Szabolcs Nagy |
f3f0ff |
#include "special/nexttowardf.h"
|
|
nsz |
ddfb9f |
|
|
nsz |
ddfb9f |
#endif
|
|
nsz |
ddfb9f |
};
|
|
nsz |
ddfb9f |
|
|
nsz |
ddfb9f |
int main(void)
|
|
nsz |
ddfb9f |
{
|
|
nsz |
ddfb9f |
#pragma STDC FENV_ACCESS ON
|
|
Szabolcs Nagy |
3feaa3 |
float y;
|
|
nsz |
ddfb9f |
float d;
|
|
nsz |
ddfb9f |
int e, i, err = 0;
|
|
nsz |
ddfb9f |
struct ll_l *p;
|
|
nsz |
ddfb9f |
|
|
nsz |
ddfb9f |
for (i = 0; i < sizeof t/sizeof *t; i++) {
|
|
nsz |
ddfb9f |
p = t + i;
|
|
nsz |
ddfb9f |
|
|
nsz |
ddfb9f |
if (p->r < 0)
|
|
nsz |
ddfb9f |
continue;
|
|
nsz |
ddfb9f |
fesetround(p->r);
|
|
nsz |
ddfb9f |
feclearexcept(FE_ALL_EXCEPT);
|
|
nsz |
ddfb9f |
y = nexttowardf(p->x, p->x2);
|
|
nsz |
ddfb9f |
e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
|
|
nsz |
ddfb9f |
|
|
Szabolcs Nagy |
cda5e0 |
if (!checkexceptall(e, p->e, p->r)) {
|
|
nsz |
ddfb9f |
printf("%s:%d: bad fp exception: %s nexttowardf(%La,%La)=%La, want %s",
|
|
nsz |
ddfb9f |
p->file, p->line, rstr(p->r), p->x, p->x2, p->y, estr(p->e));
|
|
nsz |
ddfb9f |
printf(" got %s\n", estr(e));
|
|
nsz |
ddfb9f |
err++;
|
|
nsz |
ddfb9f |
}
|
|
Szabolcs Nagy |
105b39 |
d = ulperrf(y, p->y, p->dy);
|
|
Szabolcs Nagy |
5729b0 |
if (!checkcr(y, p->y, p->r)) {
|
|
Szabolcs Nagy |
105b39 |
printf("%s:%d: %s nexttowardf(%La,%La) want %La got %a ulperr %.3f = %a + %a\n",
|
|
nsz |
ddfb9f |
p->file, p->line, rstr(p->r), p->x, p->x2, p->y, y, d, d-p->dy, p->dy);
|
|
nsz |
ddfb9f |
err++;
|
|
nsz |
ddfb9f |
}
|
|
nsz |
ddfb9f |
}
|
|
nsz |
ddfb9f |
return !!err;
|
|
nsz |
ddfb9f |
}
|