4 #define T(a,b) {__LINE__, a, b},
5 #define length(a) (sizeof(a)/sizeof*(a))
15 T(-1/0.0, FP_INFINITE)
16 T(0x1.ffffp127, FP_NORMAL)
17 T(-0x1.ffffp127, FP_NORMAL)
18 T(0x1p-127, FP_SUBNORMAL)
19 T(-0x1p-127, FP_SUBNORMAL)
34 T(-1/0.0, FP_INFINITE)
35 T(0x1.ffffp1023, FP_NORMAL)
36 T(-0x1.ffffp1023, FP_NORMAL)
37 T(0x1p-1023, FP_SUBNORMAL)
38 T(-0x1p-1023, FP_SUBNORMAL)
53 T(-1/0.0, FP_INFINITE)
54 T(0x1.ffffp16383L, FP_NORMAL)
55 T(-0x1.ffffp16383L, FP_NORMAL)
56 T(0x1p-16383L, FP_SUBNORMAL)
57 T(-0x1p-16383L, FP_SUBNORMAL)
64 static char *strclass(int c)
66 #define C(n) case n: return #n;
77 #define error(t,c) err++, printf("%s:%d: (at line %d) %La has class %d (%s), but %s returns %d\n", \
78 __FILE__, __LINE__, t.line, (long double)t.f, t.class, strclass(t.class), #c, c(t.f))
85 for (i = 0; i < length(tf); i++) {
86 if (fpclassify(tf[i].f) != tf[i].class)
87 error(tf[i], fpclassify);
88 if (!!isinf(tf[i].f) != (tf[i].class == FP_INFINITE))
90 if (!!isnan(tf[i].f) != (tf[i].class == FP_NAN))
92 if (!!isnormal(tf[i].f) != (tf[i].class == FP_NORMAL))
93 error(tf[i], isnormal);
94 if (!!isfinite(tf[i].f) != (tf[i].class > FP_INFINITE))
95 error(tf[i], isfinite);
98 for (i = 0; i < length(td); i++) {
99 if (fpclassify(td[i].f) != td[i].class)
100 error(td[i], fpclassify);
101 if (!!isinf(td[i].f) != (td[i].class == FP_INFINITE))
103 if (!!isnan(td[i].f) != (td[i].class == FP_NAN))
105 if (!!isnormal(td[i].f) != (td[i].class == FP_NORMAL))
106 error(td[i], isnormal);
107 if (!!isfinite(td[i].f) != (td[i].class > FP_INFINITE))
108 error(td[i], isfinite);
111 for (i = 0; i < length(tl); i++) {
112 if (fpclassify(tl[i].f) != tl[i].class)
113 error(tl[i], fpclassify);
114 if (!!isinf(tl[i].f) != (tl[i].class == FP_INFINITE))
116 if (!!isnan(tl[i].f) != (tl[i].class == FP_NAN))
118 if (!!isnormal(tl[i].f) != (tl[i].class == FP_NORMAL))
119 error(tl[i], isnormal);
120 if (!!isfinite(tl[i].f) != (tl[i].class > FP_INFINITE))
121 error(tl[i], isfinite);