18
18
19
19
#include " hdr/math_macros.h"
20
20
21
- #if __SIZEOF_LONG_DOUBLE__ != 16 && __SIZEOF_LONG_DOUBLE__ != 12
22
- #error "unhandled long double type"
23
- #endif
24
-
25
21
#define TEST_SPECIAL (x, y, expected, expected_exception ) \
26
22
EXPECT_EQ (expected, f(&x, &y)); \
27
23
EXPECT_FP_EXCEPTION (expected_exception); \
@@ -66,10 +62,10 @@ class CanonicalizeTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
66
62
// Exponent | Significand | Meaning
67
63
// | Bits 63-62 | Bits 61-0 |
68
64
// All Ones | 00 | Zero | Pseudo Infinity, Value = SNaN
69
- #if __SIZEOF_LONG_DOUBLE__ == 16
70
- FPBits test1 (0x00000000'00007FFF'00000000' 00000000_u128);
71
- #elif __SIZEOF_LONG_DOUBLE__ == 12
65
+ #if __SIZEOF_LONG_DOUBLE__ == 12
72
66
FPBits test1 (0x00007FFF'00000000' 00000000_u96);
67
+ #else
68
+ FPBits test1 (0x00000000'00007FFF'00000000' 00000000_u128);
73
69
#endif
74
70
const T test1_val = test1.get_val ();
75
71
TEST_SPECIAL (cx, test1_val, 1 , FE_INVALID);
@@ -78,37 +74,37 @@ class CanonicalizeTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
78
74
// Exponent | Significand | Meaning
79
75
// | Bits 63-62 | Bits 61-0 |
80
76
// All Ones | 00 | Non-Zero | Pseudo NaN, Value = SNaN
81
- #if __SIZEOF_LONG_DOUBLE__ == 16
82
- FPBits test2_1 (0x00000000'00007FFF'00000000' 00000001_u128);
83
- #elif __SIZEOF_LONG_DOUBLE__ == 12
77
+ #if __SIZEOF_LONG_DOUBLE__ == 12
84
78
FPBits test2_1 (0x00007FFF'00000000' 00000001_u96);
79
+ #else
80
+ FPBits test2_1 (0x00000000'00007FFF'00000000' 00000001_u128);
85
81
#endif
86
82
const T test2_1_val = test2_1.get_val ();
87
83
TEST_SPECIAL (cx, test2_1_val, 1 , FE_INVALID);
88
84
EXPECT_FP_EQ (cx, aNaN);
89
85
90
- #if __SIZEOF_LONG_DOUBLE__ == 16
91
- FPBits test2_2 (0x00000000'00007FFF'00000042' 70000001_u128);
92
- #elif __SIZEOF_LONG_DOUBLE__ == 12
86
+ #if __SIZEOF_LONG_DOUBLE__ == 12
93
87
FPBits test2_2 (0x00007FFF'00000042' 70000001_u96);
88
+ #else
89
+ FPBits test2_2 (0x00000000'00007FFF'00000042' 70000001_u128);
94
90
#endif
95
91
const T test2_2_val = test2_2.get_val ();
96
92
TEST_SPECIAL (cx, test2_2_val, 1 , FE_INVALID);
97
93
EXPECT_FP_EQ (cx, aNaN);
98
94
99
- #if __SIZEOF_LONG_DOUBLE__ == 16
100
- FPBits test2_3 (0x00000000'00007FFF'00000000' 08261001_u128);
101
- #elif __SIZEOF_LONG_DOUBLE__ == 12
95
+ #if __SIZEOF_LONG_DOUBLE__ == 12
102
96
FPBits test2_3 (0x00007FFF'00000000' 08261001_u96);
97
+ #else
98
+ FPBits test2_3 (0x00000000'00007FFF'00000000' 08261001_u128);
103
99
#endif
104
100
const T test2_3_val = test2_3.get_val ();
105
101
TEST_SPECIAL (cx, test2_3_val, 1 , FE_INVALID);
106
102
EXPECT_FP_EQ (cx, aNaN);
107
103
108
- #if __SIZEOF_LONG_DOUBLE__ == 16
109
- FPBits test2_4 (0x00000000'00007FFF'00007800' 08261001_u128);
110
- #elif __SIZEOF_LONG_DOUBLE__ == 12
104
+ #if __SIZEOF_LONG_DOUBLE__ == 12
111
105
FPBits test2_4 (0x00007FFF'00007800' 08261001_u96);
106
+ #else
107
+ FPBits test2_4 (0x00000000'00007FFF'00007800' 08261001_u128);
112
108
#endif
113
109
const T test2_4_val = test2_4.get_val ();
114
110
TEST_SPECIAL (cx, test2_4_val, 1 , FE_INVALID);
@@ -117,37 +113,37 @@ class CanonicalizeTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
117
113
// Exponent | Significand | Meaning
118
114
// | Bits 63-62 | Bits 61-0 |
119
115
// All Ones | 01 | Anything | Pseudo NaN, Value = SNaN
120
- #if __SIZEOF_LONG_DOUBLE__ == 16
121
- FPBits test3_1 (0x00000000'00007FFF'40000000' 00000000_u128);
122
- #elif __SIZEOF_LONG_DOUBLE__ == 12
116
+ #if __SIZEOF_LONG_DOUBLE__ == 12
123
117
FPBits test3_1 (0x00007FFF'40000000' 00000000_u96);
118
+ #else
119
+ FPBits test3_1 (0x00000000'00007FFF'40000000' 00000000_u128);
124
120
#endif
125
121
const T test3_1_val = test3_1.get_val ();
126
122
TEST_SPECIAL (cx, test3_1_val, 1 , FE_INVALID);
127
123
EXPECT_FP_EQ (cx, aNaN);
128
124
129
- #if __SIZEOF_LONG_DOUBLE__ == 16
130
- FPBits test3_2 (0x00000000'00007FFF'40000042' 70000001_u128);
131
- #elif __SIZEOF_LONG_DOUBLE__ == 12
125
+ #if __SIZEOF_LONG_DOUBLE__ == 12
132
126
FPBits test3_2 (0x00007FFF'40000042' 70000001_u96);
127
+ #else
128
+ FPBits test3_2 (0x00000000'00007FFF'40000042' 70000001_u128);
133
129
#endif
134
130
const T test3_2_val = test3_2.get_val ();
135
131
TEST_SPECIAL (cx, test3_2_val, 1 , FE_INVALID);
136
132
EXPECT_FP_EQ (cx, aNaN);
137
133
138
- #if __SIZEOF_LONG_DOUBLE__ == 16
139
- FPBits test3_3 (0x00000000'00007FFF'40000000' 08261001_u128);
140
- #elif __SIZEOF_LONG_DOUBLE__ == 12
134
+ #if __SIZEOF_LONG_DOUBLE__ == 12
141
135
FPBits test3_3 (0x00007FFF'40000000' 08261001_u96);
136
+ #else
137
+ FPBits test3_3 (0x00000000'00007FFF'40000000' 08261001_u128);
142
138
#endif
143
139
const T test3_3_val = test3_3.get_val ();
144
140
TEST_SPECIAL (cx, test3_3_val, 1 , FE_INVALID);
145
141
EXPECT_FP_EQ (cx, aNaN);
146
142
147
- #if __SIZEOF_LONG_DOUBLE__ == 16
148
- FPBits test3_4 (0x00000000'00007FFF'40007800' 08261001_u128);
149
- #elif __SIZEOF_LONG_DOUBLE__ == 12
143
+ #if __SIZEOF_LONG_DOUBLE__ == 12
150
144
FPBits test3_4 (0x00007FFF'40007800' 08261001_u96);
145
+ #else
146
+ FPBits test3_4 (0x00000000'00007FFF'40007800' 08261001_u128);
151
147
#endif
152
148
const T test3_4_val = test3_4.get_val ();
153
149
TEST_SPECIAL (cx, test3_4_val, 1 , FE_INVALID);
@@ -157,30 +153,30 @@ class CanonicalizeTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
157
153
// | Bit 63 | Bits 62-0 |
158
154
// All zeroes | One | Anything | Pseudo Denormal, Value =
159
155
// | | | (−1)**s × m × 2**−16382
160
- #if __SIZEOF_LONG_DOUBLE__ == 16
161
- FPBits test4_1 (0x00000000'00000000'80000000' 00000000_u128);
162
- #elif __SIZEOF_LONG_DOUBLE__ == 12
156
+ #if __SIZEOF_LONG_DOUBLE__ == 12
163
157
FPBits test4_1 (0x00000000'80000000' 00000000_u96);
158
+ #else
159
+ FPBits test4_1 (0x00000000'00000000'80000000' 00000000_u128);
164
160
#endif
165
161
const T test4_1_val = test4_1.get_val ();
166
162
TEST_SPECIAL (cx, test4_1_val, 0 , 0 );
167
163
EXPECT_FP_EQ (
168
164
cx, FPBits::make_value (test4_1.get_explicit_mantissa (), 0 ).get_val ());
169
165
170
- #if __SIZEOF_LONG_DOUBLE__ == 16
171
- FPBits test4_2 (0x00000000'00000000'80000042' 70000001_u128);
172
- #elif __SIZEOF_LONG_DOUBLE__ == 12
166
+ #if __SIZEOF_LONG_DOUBLE__ == 12
173
167
FPBits test4_2 (0x00000000'80000042' 70000001_u96);
168
+ #else
169
+ FPBits test4_2 (0x00000000'00000000'80000042' 70000001_u128);
174
170
#endif
175
171
const T test4_2_val = test4_2.get_val ();
176
172
TEST_SPECIAL (cx, test4_2_val, 0 , 0 );
177
173
EXPECT_FP_EQ (
178
174
cx, FPBits::make_value (test4_2.get_explicit_mantissa (), 0 ).get_val ());
179
175
180
- #if __SIZEOF_LONG_DOUBLE__ == 16
181
- FPBits test4_3 (0x00000000'00000000'80000000' 08261001_u128);
182
- #elif __SIZEOF_LONG_DOUBLE__ == 12
176
+ #if __SIZEOF_LONG_DOUBLE__ == 12
183
177
FPBits test4_3 (0x00000000'80000000' 08261001_u96);
178
+ #else
179
+ FPBits test4_3 (0x00000000'00000000'80000000' 08261001_u128);
184
180
#endif
185
181
const T test4_3_val = test4_3.get_val ();
186
182
TEST_SPECIAL (cx, test4_3_val, 0 , 0 );
@@ -191,55 +187,55 @@ class CanonicalizeTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
191
187
// | Bit 63 | Bits 62-0 |
192
188
// All Other | Zero | Anything | Unnormal, Value = SNaN
193
189
// Values | | |
194
- #if __SIZEOF_LONG_DOUBLE__ == 16
195
- FPBits test5_1 (0x00000000'00000040'00000000' 00000001_u128);
196
- #elif __SIZEOF_LONG_DOUBLE__ == 12
190
+ #if __SIZEOF_LONG_DOUBLE__ == 12
197
191
FPBits test5_1 (0x00000040'00000000' 00000001_u96);
192
+ #else
193
+ FPBits test5_1 (0x00000000'00000040'00000000' 00000001_u128);
198
194
#endif
199
195
const T test5_1_val = test5_1.get_val ();
200
196
TEST_SPECIAL (cx, test5_1_val, 1 , FE_INVALID);
201
197
EXPECT_FP_EQ (cx, aNaN);
202
198
203
- #if __SIZEOF_LONG_DOUBLE__ == 16
204
- FPBits test5_2 (0x00000000'00000230'00000042' 70000001_u128);
205
- #elif __SIZEOF_LONG_DOUBLE__ == 12
199
+ #if __SIZEOF_LONG_DOUBLE__ == 12
206
200
FPBits test5_2 (0x00000230'00000042' 70000001_u96);
201
+ #else
202
+ FPBits test5_2 (0x00000000'00000230'00000042' 70000001_u128);
207
203
#endif
208
204
const T test5_2_val = test5_2.get_val ();
209
205
TEST_SPECIAL (cx, test5_2_val, 1 , FE_INVALID);
210
206
EXPECT_FP_EQ (cx, aNaN);
211
207
212
- #if __SIZEOF_LONG_DOUBLE__ == 16
213
- FPBits test5_3 (0x00000000'00000560'00000000' 08261001_u128);
214
- #elif __SIZEOF_LONG_DOUBLE__ == 12
208
+ #if __SIZEOF_LONG_DOUBLE__ == 12
215
209
FPBits test5_3 (0x00000560'00000000' 08261001_u96);
210
+ #else
211
+ FPBits test5_3 (0x00000000'00000560'00000000' 08261001_u128);
216
212
#endif
217
213
const T test5_3_val = test5_3.get_val ();
218
214
TEST_SPECIAL (cx, test5_3_val, 1 , FE_INVALID);
219
215
EXPECT_FP_EQ (cx, aNaN);
220
216
221
- #if __SIZEOF_LONG_DOUBLE__ == 16
222
- FPBits test5_4 (0x00000000'00000780'00000028' 16000000_u128);
223
- #elif __SIZEOF_LONG_DOUBLE__ == 12
217
+ #if __SIZEOF_LONG_DOUBLE__ == 12
224
218
FPBits test5_4 (0x00000780'00000028' 16000000_u96);
219
+ #else
220
+ FPBits test5_4 (0x00000000'00000780'00000028' 16000000_u128);
225
221
#endif
226
222
const T test5_4_val = test5_4.get_val ();
227
223
TEST_SPECIAL (cx, test5_4_val, 1 , FE_INVALID);
228
224
EXPECT_FP_EQ (cx, aNaN);
229
225
230
- #if __SIZEOF_LONG_DOUBLE__ == 16
231
- FPBits test5_5 (0x00000000'00000900'00000042' 70000001_u128);
232
- #elif __SIZEOF_LONG_DOUBLE__ == 12
226
+ #if __SIZEOF_LONG_DOUBLE__ == 12
233
227
FPBits test5_5 (0x00000900'00000042' 70000001_u96);
228
+ #else
229
+ FPBits test5_5 (0x00000000'00000900'00000042' 70000001_u128);
234
230
#endif
235
231
const T test5_5_val = test5_5.get_val ();
236
232
TEST_SPECIAL (cx, test5_5_val, 1 , FE_INVALID);
237
233
EXPECT_FP_EQ (cx, aNaN);
238
234
239
- #if __SIZEOF_LONG_DOUBLE__ == 16
240
- FPBits test5_6 (0x00000000'00000AB0'00000000' 08261001_u128);
241
- #elif __SIZEOF_LONG_DOUBLE__ == 12
235
+ #if __SIZEOF_LONG_DOUBLE__ == 12
242
236
FPBits test5_6 (0x00000AB0'00000000' 08261001_u96);
237
+ #else
238
+ FPBits test5_6 (0x00000000'00000AB0'00000000' 08261001_u128);
243
239
#endif
244
240
const T test5_6_val = test5_6.get_val ();
245
241
TEST_SPECIAL (cx, test5_6_val, 1 , FE_INVALID);
0 commit comments