Blame src/math/util.h

nsz f9d179
#include <fenv.h>
nsz f9d179
#include <float.h>
nsz f9d179
#include <math.h>
nsz f9d179
nsz f9d179
#undef RN
nsz f9d179
#undef RZ
nsz f9d179
#undef RD
nsz f9d179
#undef RU
nsz f9d179
#define RN FE_TONEAREST
nsz f9d179
#define RZ FE_TOWARDZERO
nsz f9d179
#define RD FE_DOWNWARD
nsz f9d179
#define RU FE_UPWARD
nsz f9d179
nsz f9d179
#undef INEXACT
nsz f9d179
#undef INVALID
nsz f9d179
#undef DIVBYZERO
nsz f9d179
#undef UNDERFLOW
nsz f9d179
#undef OVERFLOW
nsz f9d179
#define INEXACT FE_INEXACT
nsz f9d179
#define INVALID FE_INVALID
nsz f9d179
#define DIVBYZERO FE_DIVBYZERO
nsz f9d179
#define UNDERFLOW FE_UNDERFLOW
nsz f9d179
#define OVERFLOW FE_OVERFLOW
nsz f9d179
nsz f9d179
#undef inf
nsz f9d179
#undef nan
nsz f9d179
#define inf INFINITY
nsz f9d179
#define nan NAN
nsz f9d179
nsz f9d179
#define T(...) {__FILE__, __LINE__, __VA_ARGS__},
nsz f9d179
nsz f9d179
#define POS char *file; int line;
nsz f9d179
struct d_d {POS int r; double x; double y; float dy; int e; };
nsz f9d179
struct f_f {POS int r; float x; float y; float dy; int e; };
nsz f9d179
struct l_l {POS int r; long double x; long double y; float dy; int e; };
nsz f9d179
struct ff_f {POS int r; float x; float x2; float y; float dy; int e; };
nsz f9d179
struct dd_d {POS int r; double x; double x2; double y; float dy; int e; };
nsz f9d179
struct ll_l {POS int r; long double x; long double x2; long double y; float dy; int e; };
nsz f9d179
nsz f9d179
char *estr(int);
nsz f9d179
char *rstr(int);
nsz f9d179
int rconv(int *, char *);
nsz f9d179
int econv(int *, char *);
nsz f9d179
nsz f9d179
int eulp(double);
nsz f9d179
int eulpf(float);
nsz f9d179
int eulpl(long double);
nsz f9d179
nsz f9d179
float ulperr(double got, double want, float dwant);
nsz f9d179
float ulperrf(float got, float want, float dwant);
nsz f9d179
float ulperrl(long double got, long double want, float dwant);
nsz f9d179
nsz f9d179
void setupfenv(int);
nsz f9d179
int getexcept(void);
nsz f9d179
nsz f9d179
static int checkexcept(int got, int want, int r)
nsz f9d179
{
nsz f9d179
	if (r == RN)
nsz f9d179
		return got == want || got == (want|INEXACT);
nsz f9d179
	return 1; //(got|INEXACT|UNDERFLOW) == (want|INEXACT|UNDERFLOW);
nsz f9d179
}
nsz f9d179
nsz f9d179
static int checkulp(float d, int r)
nsz f9d179
{
nsz f9d179
	if (r == RN)
nsz f9d179
		return fabsf(d) <= 1.0;
nsz f9d179
	return 1; //fabsf(d) <= 2.0;
nsz f9d179
}
nsz f9d179