Blame src/math/remquo.c

nsz 588927
#include <stdint.h>
nsz 588927
#include <stdio.h>
Szabolcs Nagy cfa23c
#include "mtest.h"
nsz 588927
nsz 588927
static struct dd_di t[] = {
nsz 588927
#include "sanity/remquo.h"
Szabolcs Nagy f3f0ff
#include "special/remquo.h"
nsz 588927
};
nsz 588927
nsz 588927
int main(void)
nsz 588927
{
nsz 588927
	#pragma STDC FENV_ACCESS ON
nsz 588927
	int yi;
nsz 588927
	double y;
nsz 588927
	float d;
nsz 588927
	int e, i, err = 0;
nsz 588927
	struct dd_di *p;
nsz 588927
nsz 588927
	for (i = 0; i < sizeof t/sizeof *t; i++) {
nsz 588927
		p = t + i;
nsz 588927
nsz 588927
		if (p->r < 0)
nsz 588927
			continue;
nsz 588927
		fesetround(p->r);
nsz 588927
		feclearexcept(FE_ALL_EXCEPT);
nsz 588927
		y = remquo(p->x, p->x2, &yi);
nsz 588927
		e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
nsz 588927
nsz 588927
		if (!checkexcept(e, p->e, p->r)) {
nsz 588927
			printf("%s:%d: bad fp exception: %s remquo(%a,%a)=%a,%lld, want %s",
nsz 588927
				p->file, p->line, rstr(p->r), p->x, p->x2, p->y, p->i, estr(p->e));
nsz 588927
			printf(" got %s\n", estr(e));
nsz 588927
			err++;
nsz 588927
		}
nsz 588927
		d = ulperr(y, p->y, p->dy);
Szabolcs Nagy 8f89d9
		if (!checkcr(y, p->y, p->r) ||
Szabolcs Nagy b3580f
		(!isnan(p->y) && (yi & 7) != (p->i & 7)) ||
Szabolcs Nagy b3580f
		(!isnan(p->y) && (yi < 0) != (p->i < 0))) {
nsz 588927
			printf("%s:%d: %s remquo(%a,%a) want %a,%lld got %a,%d ulperr %.3f = %a + %a\n",
nsz 588927
				p->file, p->line, rstr(p->r), p->x, p->x2, p->y, p->i, y, yi, d, d-p->dy, p->dy);
nsz 588927
			err++;
nsz 588927
		}
nsz 588927
	}
nsz 588927
	return !!err;
nsz 588927
}