1 /* Test conversions of signaling NaNs to and from long double. */
8 volatile long double ld_res
;
10 volatile float f_snan
= __builtin_nansf("");
11 volatile double d_snan
= __builtin_nans("");
12 volatile long double ld_snan
= __builtin_nansl("");
14 int issignaling_f(float x
)
16 union { float f
; uint32_t u
; } u
= { .f
= x
};
17 return (u
.u
& 0x7fffffff) > 0x7f800000 && (u
.u
& 0x400000) == 0;
20 int issignaling_d(double x
)
22 union { double d
; uint64_t u
; } u
= { .d
= x
};
23 return (((u
.u
& UINT64_C(0x7fffffffffffffff)) >
24 UINT64_C(0x7ff0000000000000)) &&
25 (u
.u
& UINT64_C(0x8000000000000)) == 0);
28 int issignaling_ld(long double x
)
32 struct { uint64_t sig
; uint16_t sign_exp
; } s
;
34 return ((u
.s
.sign_exp
& 0x7fff) == 0x7fff &&
35 (u
.s
.sig
>> 63) != 0 &&
36 (u
.s
.sig
& UINT64_C(0x4000000000000000)) == 0);
43 if (issignaling_ld(ld_res
)) {
44 printf("FAIL: float -> long double\n");
48 if (issignaling_ld(ld_res
)) {
49 printf("FAIL: double -> long double\n");
53 if (issignaling_d(f_res
)) {
54 printf("FAIL: long double -> float\n");
58 if (issignaling_d(d_res
)) {
59 printf("FAIL: long double -> double\n");