Blame src/math/fma.c

nsz 588927
#include <stdint.h>
nsz 588927
#include <stdio.h>
nsz 588927
#include "util.h"
nsz 588927
nsz 588927
static struct ddd_d t[] = {
nsz 588927
#include "sanity/fma.h"
nsz 588927
};
nsz 588927
nsz 588927
int main(void)
nsz 588927
{
nsz 588927
	#pragma STDC FENV_ACCESS ON
nsz 588927
	double y;
nsz 588927
	float d;
nsz 588927
	int e, i, err = 0;
nsz 588927
	struct ddd_d *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 = fma(p->x, p->x2, p->x3);
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 fma(%a,%a,%a)=%a, want %s",
nsz 588927
				p->file, p->line, rstr(p->r), p->x, p->x2, p->x3, p->y, 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 5729b0
		if (!checkcr(y, p->y, p->r)) {
nsz 588927
			printf("%s:%d: %s fma(%a,%a,%a) want %a got %a ulperr %.3f = %a + %a\n",
nsz 588927
				p->file, p->line, rstr(p->r), p->x, p->x2, p->x3, p->y, y, d, d-p->dy, p->dy);
nsz 588927
			err++;
nsz 588927
		}
nsz 588927
	}
nsz 588927
	return !!err;
nsz 588927
}