1 /* { dg-options "-std=gnu99 -O0" } */
3 /* N1150 5.2 Conversions among decimal floating types and between
4 decimal floating types and generic floating types.
7 Test various conversions involving decimal floating types. */
9 #ifndef __STDC_WANT_DEC_FP__
10 #define __STDC_WANT_DEC_FP__ 1
15 extern void abort (void);
18 /* Support compiling the test to report individual failures; default is
19 to abort as soon as a check fails. */
22 #define FAILURE { printf ("failed at line %d\n", __LINE__); failcnt++; }
24 #define FAILURE abort ();
27 volatile _Decimal32 d32;
28 volatile _Decimal64 d64;
29 volatile _Decimal128 d128;
34 /* Conversions to larger types. */
44 if (d128 != 345.678dl)
47 /* Conversions to smaller types for which the value fits. */
50 if (d32 != 3456.789df)
54 if (d32 != 123.4567df)
57 d128 = 1234567890.123456dl;
59 if (d64 != 1234567890.123456dd)
62 /* Test demotion to non-representable decimal floating type. */
64 /* Assumes a default rounding mode of 'near'. This uses the rules
65 describe in the 27 July 2005 draft of IEEE 754r, which are much
66 more clear that what's described in draft 5 of N1107. */
68 /* Rounds to what _Decimal32 can handle. */
69 d64 = 9.99999949E96DD;
74 /* Rounds to more than _Decimal32 can handle. */
77 if (d32 != __builtin_infd32())
80 /* Rounds to what _Decimal32 can handle. */
81 d128 = 9.99999949E96DD;
86 /* Rounds to more than _Decimal32 can handle. */
89 if (d32 != __builtin_infd32())
92 /* Rounds to what _Decimal64 can handle. */
93 d128 = 9.99999999999999949E384DL;
98 /* Rounds to more than _Decimal64 can handle. */
99 d128 = 9.9999999999999995E384DL;
101 if (d64 != __builtin_infd64())