1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_truncsfhf2
8 TYPE_FP16
__truncsfhf2(float a
);
10 int test__truncsfhf2(float a
, uint16_t expected
)
12 TYPE_FP16 x
= __truncsfhf2(a
);
13 int ret
= compareResultH(x
, expected
);
16 printf("error in test__truncsfhf2(%f) = %#.4x, "
17 "expected %#.4x\n", a
, toRep16(x
), expected
);
22 char assumption_1
[sizeof(TYPE_FP16
) * CHAR_BIT
== 16] = {0};
27 if (test__truncsfhf2(makeQNaN32(),
31 if (test__truncsfhf2(makeNaN32(UINT32_C(0x8000)),
35 if (test__truncsfhf2(makeInf32(),
38 if (test__truncsfhf2(-makeInf32(),
42 if (test__truncsfhf2(0.0f
, UINT16_C(0x0)))
44 if (test__truncsfhf2(-0.0f
, UINT16_C(0x8000)))
47 if (test__truncsfhf2(3.1415926535f
,
50 if (test__truncsfhf2(-3.1415926535f
,
53 if (test__truncsfhf2(0x1.987124876876324p
+100f
,
56 if (test__truncsfhf2(0x1.987124876876324p
+12f
,
59 if (test__truncsfhf2(0x1.0p
+0f
,
62 if (test__truncsfhf2(0x1.0p
-14f
,
66 if (test__truncsfhf2(0x1.0p
-20f
,
69 if (test__truncsfhf2(0x1.0p
-24f
,
72 if (test__truncsfhf2(-0x1.0p
-24f
,
75 if (test__truncsfhf2(0x1.5p
-25f
,
79 if (test__truncsfhf2(0x1.0p
-25f
,
82 if (test__truncsfhf2(-0x1.0p
-25f
,
86 if (test__truncsfhf2(65504.0f
,
90 if (test__truncsfhf2(65519.0f
,
94 if (test__truncsfhf2(65520.0f
,
97 if (test__truncsfhf2(65536.0f
,
100 if (test__truncsfhf2(-65520.0f
,