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);
17 volatile _Decimal32 d32;
18 volatile _Decimal64 d64;
19 volatile _Decimal128 d128;
24 /* Conversions to larger types. */
34 if (d128 != 345.678dl)
37 /* Conversions to smaller types for which the value fits. */
40 if (d32 != 3456.789df)
44 if (d32 != 123.4567dl)
47 d128 = 1234567890.123456dl;
49 if (d64 != 1234567890.123456dd)
52 /* Test demotion to non-representable decimal floating type. */
54 /* Assumes a default rounding mode of 'near'. This uses the rules
55 describe in the 27 July 2005 draft of IEEE 754r, which are much
56 more clear that what's described in draft 5 of N1107. */
58 /* Rounds to what _Decimal32 can handle. */
59 d64 = 9.99999949E96DD;
64 /* Rounds to more than _Decimal32 can handle. */
67 if (d32 != __builtin_infd32())
70 /* Rounds to what _Decimal32 can handle. */
71 d128 = 9.99999949E96DD;
76 /* Rounds to more than _Decimal32 can handle. */
79 if (d32 != __builtin_infd32())
82 /* Rounds to what _Decimal64 can handle. */
83 d128 = 9.99999999999999949E384DL;
88 /* Rounds to more than _Decimal64 can handle. */
89 d128 = 9.9999999999999995E384DL;
91 if (d64 != __builtin_infd64())