Blame src/math/llroundl.c

nsz b5bbc6
#include <stdint.h>
nsz b5bbc6
#include <stdio.h>
nsz b5bbc6
#include "util.h"
nsz b5bbc6
nsz b5bbc6
static struct l_i t[] = {
nsz b5bbc6
#if LDBL_MANT_DIG == 53
nsz b5bbc6
#include "sanity/llround.h"
nsz b5bbc6
nsz b5bbc6
#elif LDBL_MANT_DIG == 64
nsz b5bbc6
#include "sanity/llroundl.h"
nsz b5bbc6
nsz b5bbc6
#endif
nsz b5bbc6
};
nsz b5bbc6
nsz b5bbc6
int main(void)
nsz b5bbc6
{
nsz b5bbc6
	#pragma STDC FENV_ACCESS ON
nsz e08422
	long long yi;
nsz b5bbc6
	int e, i, err = 0;
nsz b5bbc6
	struct l_i *p;
nsz b5bbc6
nsz b5bbc6
	for (i = 0; i < sizeof t/sizeof *t; i++) {
nsz b5bbc6
		p = t + i;
nsz b5bbc6
nsz b5bbc6
		if (p->r < 0)
nsz b5bbc6
			continue;
nsz b5bbc6
		fesetround(p->r);
nsz b5bbc6
		feclearexcept(FE_ALL_EXCEPT);
nsz b5bbc6
		yi = llroundl(p->x);
nsz b5bbc6
		e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);
nsz b5bbc6
nsz b5bbc6
		if (!checkexcept(e, p->e, p->r)) {
nsz b5bbc6
			printf("%s:%d: bad fp exception: %s llroundl(%La)=%lld, want %s",
nsz b5bbc6
				p->file, p->line, rstr(p->r), p->x, p->i, estr(p->e));
nsz b5bbc6
			printf(" got %s\n", estr(e));
nsz b5bbc6
			err++;
nsz b5bbc6
		}
nsz b5bbc6
		if (yi != p->i) {
nsz e08422
			printf("%s:%d: %s llroundl(%La) want %lld got %lld\n",
nsz b5bbc6
				p->file, p->line, rstr(p->r), p->x, p->i, yi);
nsz b5bbc6
			err++;
nsz b5bbc6
		}
nsz b5bbc6
	}
nsz b5bbc6
	return !!err;
nsz b5bbc6
}