2 /* { dg-do run { target { int128 && bitint } } } */
3 /* { dg-options "-O2 -std=gnu2x" } */
5 #define INT128_MAX ((__int128) ((((unsigned __int128) 1) << 127) - 1))
6 #define UINT128_MAX (~(unsigned __int128) 0)
7 #define C(x, y) ((((__int128) (x##ULL)) << 64) | (y##ULL))
8 #define UC(x, y) ((((unsigned __int128) (x##ULL)) << 64) | (y##ULL))
10 __attribute__((noipa
)) __int128
11 tests64 (_Decimal64 d
)
16 __attribute__((noipa
)) unsigned __int128
17 testu64 (_Decimal64 d
)
22 __attribute__((noipa
)) __int128
23 tests32 (_Decimal32 d
)
28 __attribute__((noipa
)) unsigned __int128
29 testu32 (_Decimal32 d
)
34 __attribute__((noipa
)) __int128
35 tests128 (_Decimal128 d
)
40 __attribute__((noipa
)) unsigned __int128
41 testu128 (_Decimal128 d
)
49 if (tests64 (0.DD
) != 0
50 || tests64 (0.9999999999999999DD
) != 0
51 || tests64 (7.999999999999999DD
) != 7
52 || tests64 (-0.DD
) != 0
53 || tests64 (-0.9999999999999999DD
) != 0
54 || tests64 (-42.5DD
) != -42
55 || tests64 (-34242319854.45429e+27DD
) != -C (0x19c2d4b6fefc3378, 0xa349b93967400000)
56 || tests64 (-213855087769445.9e+23DD
) != -C (0x1016b2fcff8f2cf6, 0xd16cf61904c00000)
57 || tests64 (1701411834604692.0e+23DD
) != C (0x7ffffffffffff947, 0xd26076f482000000)
58 || tests64 (-1701411834604692.0e+23DD
) != -C (0x7ffffffffffff947, 0xd26076f482000000))
60 if (tests64 (1701411834604693.0e+23DD
) != INT128_MAX
61 || tests64 (9999999999999999e+369DD
) != INT128_MAX
62 || tests64 (-1701411834604693.0e+23DD
) != -INT128_MAX
- 1
63 || tests64 (-9999999999999999e+369DD
) != -INT128_MAX
- 1)
65 if (testu64 (0.DD
) != 0
66 || testu64 (0.9999999999999999DD
) != 0
67 || testu64 (-0.9999999999999999DD
) != 0
68 || testu64 (-0.0DD
) != 0
69 || testu64 (-0.5DD
) != 0
70 || testu64 (42.99999999999999DD
) != 42
71 || testu64 (42.e
+21DD
) != UC (0x8e4, 0xd316827686400000)
72 || testu64 (34272319854.45429e+27DD
) != C (0x19c89bd43b04cab9, 0x49f2646567400000)
73 || testu64 (3402823669209384.0e+23DD
) != C (0xfffffffffffff28f, 0xa4c0ede904000000))
75 if (testu64 (-1.DD
) != 0
76 || testu64 (-42.5e+15DD
) != 0
77 || testu64 (-9999999999999999e+369DD
) != 0
78 || testu64 (3402823669209385.0e+23DD
) != UINT128_MAX
79 || testu64 (9999999999999999e+369DD
) != UINT128_MAX
)
82 if (tests32 (0.DF
) != 0
83 || tests32 (0.9999999DF
) != 0
84 || tests32 (7.999999DF
) != 7
85 || tests32 (-0.000DF
) != 0
86 || tests32 (-0.9999999DF
) != 0
87 || tests32 (-1.DF
) != -1
88 || tests32 (-42.5DF
) != -42
89 || tests32 (-3424.231e+27DF
) != -C (0x2b38497f00, 0x9c4e190b47000000)
90 || tests32 (-213855.9e+32DF
) != -C (0x1016b6fe2d67e732, 0x717a483980000000)
91 || tests32 (1701411.0e+32DF
) != C (0x7ffffbe294adefda, 0xd863b4a300000000)
92 || tests32 (-1701411.0e+32DF
) != -C (0x7ffffbe294adefda, 0xd863b4a300000000))
94 if (tests32 (1701412.0e+32DF
) != INT128_MAX
95 || tests32 (9999999e+90DF
) != INT128_MAX
96 || tests32 (-1701412.0e+32DF
) != -INT128_MAX
- 1
97 || tests32 (-9999999e+90DF
) != -INT128_MAX
- 1)
99 if (testu32 (0.DF
) != 0
100 || testu32 (0.9999999DF
) != 0
101 || testu32 (-0.9999999DF
) != 0
102 || testu32 (-0.5DF
) != 0
103 || testu32 (-0.0000DF
) != 0
104 || testu32 (-0.99999DF
) != 0
105 || testu32 (42.99999DF
) != 42
106 || testu32 (42.e
+21DF
) != UC (0x8e4, 0xd316827686400000)
107 || testu32 (3402.823e+35DF
) != UC (0xfffffcb356c92111, 0x367458c700000000))
109 if (testu32 (-1.DF
) != 0
110 || testu32 (-42.5e+15DF
) != 0
111 || testu32 (-9999999e+90DF
) != 0
112 || testu32 (3402.824e+35DF
) != UINT128_MAX
113 || testu32 (9999999e+90DF
) != UINT128_MAX
)
116 if (tests128 (0.DL
) != 0
117 || tests128 (0.9999999999999999999999999999999999DL
) != 0
118 || tests128 (7.999999999999999999999999999999999DL
) != 7
119 || tests128 (-0.DL
) != 0
120 || tests128 (-0.9999999999999999999999999999999999DL
) != 0
121 || tests128 (-1.DL
) != -1
122 || tests128 (-42.5DL
) != -42
123 || tests128 (-34242319854.45429439857871298745432e+27DL
) != -C (0x19c2d4b6fefc3467, 0x15d47c047b56ad80)
124 || tests128 (-213855087769445.9e+23DL
) != -C (0x1016b2fcff8f2cf6, 0xd16cf61904c00000)
125 || tests128 (1701411834604692317316873037158841.0e+5DL
) != C (0x7fffffffffffffff, 0xffffffffffffe9a0)
126 || tests128 (-1701411834604692317316873037158841.0e+5DL
) != -C (0x7fffffffffffffff, 0xffffffffffffe9a0))
128 if (tests128 (1701411834604692317316873037158842.0e+5DL
) != INT128_MAX
129 || tests128 (9999999999999999999999999999999999e+6111DL
) != INT128_MAX
130 || tests128 (-1701411834604692317316873037158842.0e+5DL
) != -INT128_MAX
- 1
131 || tests128 (-9999999999999999999999999999999999e+6111DL
) != -INT128_MAX
- 1)
133 if (testu128 (0.DL
) != 0
134 || testu128 (0.9999999999999999999999999999999999DL
) != 0
135 || testu128 (-0.9999999999999999999999999999999999DL
) != 0
136 || testu128 (-0.DL
) != 0
137 || testu128 (-0.9999999999999999999999DL
) != 0
138 || testu128 (-0.5DL
) != 0
139 || testu128 (42.99999999999999999999999999999999DL
) != 42
140 || testu128 (42.e
+21DL
) != UC (0x8e4, 0xd316827686400000)
141 || testu128 (34242319854.45429439857871298745432e+21DL
) != UC (0x1b032e71cc9, 0x24b5cd6d86a9473e)
142 || testu128 (3402823669209384634633746074317.682e+8DL
) != UC (0xffffffffffffffff, 0xffffffffffffd340))
144 if (testu128 (-1.DL
) != 0
145 || testu128 (-42.5e+15DL
) != 0
146 || testu128 (-9999999999999999999999999999999999e+6111DL
) != 0
147 || testu128 (3402823669209384634633746074317.683e+8DL
) != UINT128_MAX
148 || testu128 (9999999999999999999999999999999999e+6111DL
) != UINT128_MAX
)