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 #if LDBL_MAX_EXP==16384
55 T(0x1.ffffp16383L
, FP_NORMAL
)
56 T(-0x1.ffffp16383L
, FP_NORMAL
)
57 T(0x1p
-16383L, FP_SUBNORMAL
)
58 T(-0x1p
-16383L, FP_SUBNORMAL
)
59 #elif LDBL_MAX_EXP==1024
60 T(0x1.ffffp1023L
, FP_NORMAL
)
61 T(-0x1.ffffp1023L
, FP_NORMAL
)
62 T(0x1p
-1023L, FP_SUBNORMAL
)
63 T(-0x1p
-1023L, FP_SUBNORMAL
)
71 static char *strclass(int c
)
73 #define C(n) case n: return #n;
84 #define error(t,c) err++, printf("%s:%d: (at line %d) %La has class %d (%s), but %s returns %d\n", \
85 __FILE__, __LINE__, t.line, (long double)t.f, t.class, strclass(t.class), #c, c(t.f))
92 for (i
= 0; i
< length(tf
); i
++) {
93 if (fpclassify(tf
[i
].f
) != tf
[i
].class)
94 error(tf
[i
], fpclassify
);
95 if (!!isinf(tf
[i
].f
) != (tf
[i
].class == FP_INFINITE
))
97 if (!!isnan(tf
[i
].f
) != (tf
[i
].class == FP_NAN
))
99 if (!!isnormal(tf
[i
].f
) != (tf
[i
].class == FP_NORMAL
))
100 error(tf
[i
], isnormal
);
101 if (!!isfinite(tf
[i
].f
) != (tf
[i
].class > FP_INFINITE
))
102 error(tf
[i
], isfinite
);
105 for (i
= 0; i
< length(td
); i
++) {
106 if (fpclassify(td
[i
].f
) != td
[i
].class)
107 error(td
[i
], fpclassify
);
108 if (!!isinf(td
[i
].f
) != (td
[i
].class == FP_INFINITE
))
110 if (!!isnan(td
[i
].f
) != (td
[i
].class == FP_NAN
))
112 if (!!isnormal(td
[i
].f
) != (td
[i
].class == FP_NORMAL
))
113 error(td
[i
], isnormal
);
114 if (!!isfinite(td
[i
].f
) != (td
[i
].class > FP_INFINITE
))
115 error(td
[i
], isfinite
);
118 for (i
= 0; i
< length(tl
); i
++) {
119 if (fpclassify(tl
[i
].f
) != tl
[i
].class)
120 error(tl
[i
], fpclassify
);
121 if (!!isinf(tl
[i
].f
) != (tl
[i
].class == FP_INFINITE
))
123 if (!!isnan(tl
[i
].f
) != (tl
[i
].class == FP_NAN
))
125 if (!!isnormal(tl
[i
].f
) != (tl
[i
].class == FP_NORMAL
))
126 error(tl
[i
], isnormal
);
127 if (!!isfinite(tl
[i
].f
) != (tl
[i
].class > FP_INFINITE
))
128 error(tl
[i
], isfinite
);