1 // commit: f657fe4b9f734d7fdea515af8dffbf7c28ce4fbc 2013-09-05
2 // classify invalid x86 ld80 representations (this is ub, we follow the fpu)
3 // test printf("%La") as well
12 static char *strclass(int c
)
14 #define C(n) case n: return #n;
25 #define T(f, desc, c, cwant, s, swant) do{ \
28 t_error("fpclassify(%s) failed: got %s want %s\n", desc, strclass(c), #cwant); \
29 memset(s, 0, sizeof(s)); \
30 if (snprintf(s, sizeof(s), "%La", f) >= sizeof(s)) \
31 t_error("snprintf(\"%%La\", %s) failed with invalid return value\n", desc); \
32 if (strcmp(s,swant) != 0) \
33 t_error("snprintf(\"%%La\", %s) failed: got \"%.*s\" want %s\n", desc, sizeof(s), s, #swant); \
50 u
.i
.m
= (uint64_t)1<<63;
51 T(u
.f
, "zero with msb set", c
, FP_NORMAL
, s
, "0x1p-16382");
53 T(u
.f
, "subnormal with msb set", c
, FP_NORMAL
, s
, "0x1.0000000000000002p-16382");
56 T(u
.f
, "normal with msb unset", c
, FP_NAN
, s
, "nan");
59 T(u
.f
, "infinity with msb unset", c
, FP_NAN
, s
, "nan");
61 u
.i
.m
&=(uint64_t)-1/2;
62 T(u
.f
, "nan with msb unset", c
, FP_NAN
, s
, "nan");