10 #define RN FE_TONEAREST
15 #define RZ FE_TOWARDZERO
20 #define RD FE_DOWNWARD
36 #define INEXACT FE_INEXACT
41 #define INVALID FE_INVALID
46 #define DIVBYZERO FE_DIVBYZERO
51 #define UNDERFLOW FE_UNDERFLOW
56 #define OVERFLOW FE_OVERFLOW
66 #define T(...) {__FILE__, __LINE__, __VA_ARGS__},
68 #define POS char *file; int line;
69 struct d_d {POS int r; double x; double y; float dy; int e; };
70 struct f_f {POS int r; float x; float y; float dy; int e; };
71 struct l_l {POS int r; long double x; long double y; float dy; int e; };
72 struct ff_f {POS int r; float x; float x2; float y; float dy; int e; };
73 struct dd_d {POS int r; double x; double x2; double y; float dy; int e; };
74 struct ll_l {POS int r; long double x; long double x2; long double y; float dy; int e; };
75 struct d_di {POS int r; double x; double y; float dy; long long i; int e; };
76 struct f_fi {POS int r; float x; float y; float dy; long long i; int e; };
77 struct l_li {POS int r; long double x; long double y; float dy; long long i; int e; };
78 struct di_d {POS int r; double x; long long i; double y; float dy; int e; };
79 struct fi_f {POS int r; float x; long long i; float y; float dy; int e; };
80 struct li_l {POS int r; long double x; long long i; long double y; float dy; int e; };
81 struct d_i {POS int r; double x; long long i; int e; };
82 struct f_i {POS int r; float x; long long i; int e; };
83 struct l_i {POS int r; long double x; long long i; int e; };
84 struct d_dd {POS int r; double x; double y; float dy; double y2; float dy2; int e; };
85 struct f_ff {POS int r; float x; float y; float dy; float y2; float dy2; int e; };
86 struct l_ll {POS int r; long double x; long double y; float dy; long double y2; float dy2; int e; };
87 struct ff_fi {POS int r; float x; float x2; float y; float dy; long long i; int e; };
88 struct dd_di {POS int r; double x; double x2; double y; float dy; long long i; int e; };
89 struct ll_li {POS int r; long double x; long double x2; long double y; float dy; long long i; int e; };
90 struct fff_f {POS int r; float x; float x2; float x3; float y; float dy; int e; };
91 struct ddd_d {POS int r; double x; double x2; double x3; double y; float dy; int e; };
92 struct lll_l {POS int r; long double x; long double x2; long double x3; long double y; float dy; int e; };
98 float ulperr(double got, double want, float dwant);
99 float ulperrf(float got, float want, float dwant);
100 float ulperrl(long double got, long double want, float dwant);
102 static int checkexcept(int got, int want, int r)
105 #if defined CHECK_INEXACT
107 #elif defined CHECK_INEXACT_OMISSION
108 return got == want || got == (want|INEXACT);
110 return (got|INEXACT) == (want|INEXACT);
112 return (got|INEXACT|UNDERFLOW) == (want|INEXACT|UNDERFLOW);
115 static int checkexceptall(int got, int want, int r)
120 static int checkulp(float d, int r)
122 // TODO: we only care about >=1.5 ulp errors for now, should be 1.0
124 return fabsf(d) < 1.5;
125 // accept larger error in non-nearest rounding mode
126 return fabsf(d) < 3.0;
129 static int checkcr(long double y, long double ywant, int r)
133 return y == ywant && signbit(y) == signbit(ywant);