1 //===-- floattisf_test.c - Test __floattisf -------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file tests __floattisf for the compiler_rt library.
12 //===----------------------------------------------------------------------===//
20 // Returns: convert a to a float, rounding toward even.
22 // Assumption: float is a IEEE 32 bit floating point type
23 // ti_int is a 64 bit integral type
25 // seee eeee emmm mmmm mmmm mmmm mmmm mmmm
27 float __floattisf(ti_int a
);
29 int test__floattisf(ti_int a
, float expected
)
31 float x
= __floattisf(a
);
36 printf("error in __floattisf(0x%.16llX%.16llX) = %a, expected %a\n",
37 at
.s
.high
, at
.s
.low
, x
, expected
);
42 char assumption_1
[sizeof(ti_int
) == 2*sizeof(di_int
)] = {0};
43 char assumption_2
[sizeof(ti_int
)*CHAR_BIT
== 128] = {0};
44 char assumption_3
[sizeof(float)*CHAR_BIT
== 32] = {0};
51 if (test__floattisf(0, 0.0F
))
54 if (test__floattisf(1, 1.0F
))
56 if (test__floattisf(2, 2.0F
))
58 if (test__floattisf(-1, -1.0F
))
60 if (test__floattisf(-2, -2.0F
))
63 if (test__floattisf(0x7FFFFF8000000000LL
, 0x1.FFFFFEp
+62F
))
65 if (test__floattisf(0x7FFFFF0000000000LL
, 0x1.FFFFFCp
+62F
))
68 if (test__floattisf(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0x8000008000000000LL
),
71 if (test__floattisf(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0x8000010000000000LL
),
75 if (test__floattisf(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0x8000000000000000LL
),
78 if (test__floattisf(make_ti(0xFFFFFFFFFFFFFFFFLL
, 0x8000000000000001LL
),
82 if (test__floattisf(0x0007FB72E8000000LL
, 0x1.FEDCBAp
+50F
))
85 if (test__floattisf(0x0007FB72EA000000LL
, 0x1.FEDCBAp
+50F
))
87 if (test__floattisf(0x0007FB72EB000000LL
, 0x1.FEDCBAp
+50F
))
89 if (test__floattisf(0x0007FB72EBFFFFFFLL
, 0x1.FEDCBAp
+50F
))
91 if (test__floattisf(0x0007FB72EC000000LL
, 0x1.FEDCBCp
+50F
))
93 if (test__floattisf(0x0007FB72E8000001LL
, 0x1.FEDCBAp
+50F
))
96 if (test__floattisf(0x0007FB72E6000000LL
, 0x1.FEDCBAp
+50F
))
98 if (test__floattisf(0x0007FB72E7000000LL
, 0x1.FEDCBAp
+50F
))
100 if (test__floattisf(0x0007FB72E7FFFFFFLL
, 0x1.FEDCBAp
+50F
))
102 if (test__floattisf(0x0007FB72E4000001LL
, 0x1.FEDCBAp
+50F
))
104 if (test__floattisf(0x0007FB72E4000000LL
, 0x1.FEDCB8p
+50F
))
107 if (test__floattisf(make_ti(0x0007FB72E8000000LL
, 0), 0x1.FEDCBAp
+114F
))
110 if (test__floattisf(make_ti(0x0007FB72EA000000LL
, 0), 0x1.FEDCBAp
+114F
))
112 if (test__floattisf(make_ti(0x0007FB72EB000000LL
, 0), 0x1.FEDCBAp
+114F
))
114 if (test__floattisf(make_ti(0x0007FB72EBFFFFFFLL
, 0), 0x1.FEDCBAp
+114F
))
116 if (test__floattisf(make_ti(0x0007FB72EC000000LL
, 0), 0x1.FEDCBCp
+114F
))
118 if (test__floattisf(make_ti(0x0007FB72E8000001LL
, 0), 0x1.FEDCBAp
+114F
))
121 if (test__floattisf(make_ti(0x0007FB72E6000000LL
, 0), 0x1.FEDCBAp
+114F
))
123 if (test__floattisf(make_ti(0x0007FB72E7000000LL
, 0), 0x1.FEDCBAp
+114F
))
125 if (test__floattisf(make_ti(0x0007FB72E7FFFFFFLL
, 0), 0x1.FEDCBAp
+114F
))
127 if (test__floattisf(make_ti(0x0007FB72E4000001LL
, 0), 0x1.FEDCBAp
+114F
))
129 if (test__floattisf(make_ti(0x0007FB72E4000000LL
, 0), 0x1.FEDCB8p
+114F
))