1/* { dg-options "-O0 -w" } */ 2 3/* N1150 5.1 Conversions from decimal float to integer. */ 4 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). */ 8 9#include "dfp-dbg.h" 10 11volatile _Decimal32 d32; 12volatile _Decimal64 d64; 13volatile _Decimal128 d128; 14volatile int si; 15volatile unsigned int ui; 16volatile long long sll; 17volatile unsigned long long ull; 18 19void 20doit () 21{ 22 /* _Decimal32 to int. */ 23 24 d32 = 2147483.E3DF; 25 si = d32; 26 if (si != 2147483000) 27 FAILURE 28 29 d32 = -2147483.E3DF; 30 si = d32; 31 if (si != -2147483000) 32 FAILURE 33 34 /* _Decimal32 to unsigned int. */ 35 36 d32 = 4.294967E9DF; 37 ui = d32; 38 if (ui != 4294967000U) 39 FAILURE 40 41 /* _Decimal32 to long long. */ 42 43 d32 = 922.3372E16DF; 44 sll = d32; 45 if (sll != 9223372000000000000LL) 46 FAILURE 47 48 d32 = -92233.72E14DF; 49 sll = d32; 50 if (sll != -9223372000000000000LL) 51 FAILURE 52 53 /* _Decimal32 to unsigned long long. */ 54 55 d32 = .1844674E20DF; 56 ull = d32; 57 if (ull != 18446740000000000000ULL) 58 FAILURE 59 60 /* _Decimal64 to int. */ 61 62 d64 = 2.147483647E9DD; 63 si = d64; 64 if (si != 2147483647) 65 FAILURE 66 67 d64 = -2147483648.DD; 68 si = d64; 69 if (si != -2147483648) 70 FAILURE 71 72 /* _Decimal64 to unsigned int. */ 73 74 d64 = 42949.67295E5DD; 75 ui = d64; 76 if (ui != 4294967295) 77 FAILURE 78 79 /* _Decimal64 to long long. */ 80 81 d64 = 9.223372036854775E18DD; 82 sll = d64; 83 if (sll != 9223372036854775000LL) 84 FAILURE 85 86 d64 = -92233720.36854775E11DD; 87 sll = d64; 88 if (sll != -9223372036854775000LL) 89 FAILURE 90 91 /* _Decimal64 to unsigned long long. */ 92 d64 = 1844674407370955.E4DD; 93 ull = d64; 94 if (ull != 18446744073709550000ULL) 95 FAILURE 96 97 /* _Decimal128 to int. */ 98 99 d128 = 2.147483647E9DL; 100 si = d128; 101 if (si != 2147483647) 102 FAILURE 103 104 d128 = -2147483648.DL; 105 si = d128; 106 if (si != -2147483648) 107 FAILURE 108 109 /* _Decimal128 to unsigned int. */ 110 111 d128 = 4294.967295E6DL; 112 ui = d128; 113 if (ui != 4294967295) 114 FAILURE 115 116 /* _Decimal128 to long long. */ 117 118 d128 = 9223372036854775807.DL; 119 sll = d128; 120 if (sll != 9223372036854775807LL) 121 FAILURE 122 123 d128 = -9.223372036854775808E19DL; 124 sll = d128; 125 if (sll != -9223372036854775807LL - 1LL) 126 FAILURE 127 128 /* _Decimal128 to unsigned long long. */ 129 d128 = 18446744073709551615.DL; 130 ull = d128; 131 if (ull != 18446744073709551615ULL) 132 FAILURE 133} 134 135int 136main () 137{ 138 /* This test assumes 32-bit int and 64-bit long long. */ 139 140 if (sizeof (int) != 4 || sizeof (long long) != 8) 141 return 0; 142 143 doit (); 144 145 FINISH 146} 147