* ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch
[official-gcc.git] / gcc / testsuite / c-c++-common / dfp / convert-int-max.c
blob724627d376303ec1ef18cc3b470564cce6491dd7
1 /* { dg-options "-O0 -w" } */
3 /* N1150 5.1 Conversions from decimal float to integer. */
5 /* Test decimal float to integer conversions for values at the limit of
6 what will fit into the destination type. This assumes 32-bit int and
7 64-bit long long (there's a check for that below). */
9 #include "dfp-dbg.h"
11 volatile _Decimal32 d32;
12 volatile _Decimal64 d64;
13 volatile _Decimal128 d128;
14 volatile int si;
15 volatile unsigned int ui;
16 volatile long long sll;
17 volatile unsigned long long ull;
19 void
20 doit ()
22 /* _Decimal32 to int. */
24 d32 = 2147483.E3DF;
25 si = d32;
26 if (si != 2147483000)
27 FAILURE
29 d32 = -2147483.E3DF;
30 si = d32;
31 if (si != -2147483000)
32 FAILURE
34 /* _Decimal32 to unsigned int. */
36 d32 = 4.294967E9DF;
37 ui = d32;
38 if (ui != 4294967000U)
39 FAILURE
41 /* _Decimal32 to long long. */
43 d32 = 922.3372E16DF;
44 sll = d32;
45 if (sll != 9223372000000000000LL)
46 FAILURE
48 d32 = -92233.72E14DF;
49 sll = d32;
50 if (sll != -9223372000000000000LL)
51 FAILURE
53 /* _Decimal32 to unsigned long long. */
55 d32 = .1844674E20DF;
56 ull = d32;
57 if (ull != 18446740000000000000ULL)
58 FAILURE
60 /* _Decimal64 to int. */
62 d64 = 2.147483647E9DD;
63 si = d64;
64 if (si != 2147483647)
65 FAILURE
67 d64 = -2147483648.DD;
68 si = d64;
69 if (si != -2147483648)
70 FAILURE
72 /* _Decimal64 to unsigned int. */
74 d64 = 42949.67295E5DD;
75 ui = d64;
76 if (ui != 4294967295)
77 FAILURE
79 /* _Decimal64 to long long. */
81 d64 = 9.223372036854775E18DD;
82 sll = d64;
83 if (sll != 9223372036854775000LL)
84 FAILURE
86 d64 = -92233720.36854775E11DD;
87 sll = d64;
88 if (sll != -9223372036854775000LL)
89 FAILURE
91 /* _Decimal64 to unsigned long long. */
92 d64 = 1844674407370955.E4DD;
93 ull = d64;
94 if (ull != 18446744073709550000ULL)
95 FAILURE
97 /* _Decimal128 to int. */
99 d128 = 2.147483647E9DL;
100 si = d128;
101 if (si != 2147483647)
102 FAILURE
104 d128 = -2147483648.DL;
105 si = d128;
106 if (si != -2147483648)
107 FAILURE
109 /* _Decimal128 to unsigned int. */
111 d128 = 4294.967295E6DL;
112 ui = d128;
113 if (ui != 4294967295)
114 FAILURE
116 /* _Decimal128 to long long. */
118 d128 = 9223372036854775807.DL;
119 sll = d128;
120 if (sll != 9223372036854775807LL)
121 FAILURE
123 d128 = -9.223372036854775808E19DL;
124 sll = d128;
125 if (sll != -9223372036854775807LL - 1LL)
126 FAILURE
128 /* _Decimal128 to unsigned long long. */
129 d128 = 18446744073709551615.DL;
130 ull = d128;
131 if (ull != 18446744073709551615ULL)
132 FAILURE
136 main ()
138 /* This test assumes 32-bit int and 64-bit long long. */
140 if (sizeof (int) != 4 || sizeof (long long) != 8)
141 return 0;
143 doit ();
145 FINISH