1 /* { dg-options "-std=gnu99 -w" } */
3 /* This test assumes IEEE float and double. */
5 #define __STDC_WANT_DEC_FP__
10 volatile _Decimal32 sd
;
11 volatile _Decimal64 dd
;
12 volatile _Decimal128 td
;
15 volatile long double tf
;
17 CONVERT_VALID (101, td
, sf
, 0.000488281251dl
, 0.00048828125f
, 0.f
)
19 /* 2**(-25) = 0.298023223876953125E-7. */
20 CONVERT_VALID (102, td
, sf
, 2.98023223876953125e-8dl
, 2.9802322387695312e-08f
,
23 /* Fractional part doesn't fit. */
24 CONVERT_VALID (103, df
, sd
, 1.0e-20, 1.0e-20df
, 0.df
)
26 /* Exact power of 2. */
27 CONVERT_VALID (104, df
, sd
, 0.00048828125, 0.00048828125df
, 0.df
)
28 CONVERT_VALID (105, df
, sd
, 1.0e-96, 0.dd
, DEC32_MIN
)
30 /* A value slightly less than FLT_MAX can be converted in both directions. */
31 CONVERT_VALID (201, sf
, sd
, 3.402819e+38f
, 3.402819e+38df
, 0.df
)
32 CONVERT_VALID (202, sd
, sf
, 3.402819e+38df
, 3.402819e+38f
, 0.f
)
33 CONVERT_VALID (203, sf
, dd
, 3.402819e+38f
, 3.402819e+38dd
, 1.e
+30dd
)
34 CONVERT_VALID (204, dd
, sf
, 3.402819e+38dd
, 3.402819e+38f
, 0.f
)
35 CONVERT_VALID (205, sf
, td
, 3.402819e+38f
, 3.402819e+38dl
, 1.e
+30dl
)
36 CONVERT_VALID (206, td
, sf
, 3.402819e+38dl
, 3.402819e+38f
, 0.f
)
38 /* A value slightly less than DEC32_MAX can be converted in both directions. */
39 CONVERT_VALID (211, sd
, df
, 9.999998e96df
, 9.999998e96
, 0.)
40 CONVERT_VALID (212, df
, sd
, 9.999998e96
, 9.999998e96df
, 0.df
)
42 /* A value slightly less than DBL_MAX can be converted in both directions. */
43 CONVERT_VALID (221, df
, dd
, 1.79768e+308, 1.79768e+308dd
, 0.dd
)
44 CONVERT_VALID (222, dd
, df
, 1.79768e+308dd
, 1.79768e+308, 0.)
45 CONVERT_VALID (223, df
, td
, 1.79768e+308, 1.79768e+308dl
, 1.e292dl
)
46 CONVERT_VALID (224, td
, df
, 1.79768e+308dl
, 1.79768e+308, 0.)
48 /* An integral value with 6 digits (FLT_DIG) can be converted between float
49 and _Decimal32 in both directions. */
50 CONVERT_VALID (301, sd
, sf
, 100000.DF
, 100000.F
, 0.F
)
51 CONVERT_VALID (302, sf
, sd
, 100000.F
, 100000.DF
, 0.DF
)
52 CONVERT_VALID (303, sd
, sf
, 999999.DF
, 999999.F
, 0.F
)
53 CONVERT_VALID (304, sf
, sd
, 999999.F
, 999999.DF
, 0.DF
)
55 /* An integral value with 7 digits (DEC32_MANT_DIG) can be converted between
56 _Decimal32 and double in both directions. */
57 CONVERT_VALID (311, sd
, df
, 1000000.DF
, 1000000., 0.)
58 CONVERT_VALID (312, df
, sd
, 1000000., 1000000.DF
, 0.DF
)
59 CONVERT_VALID (313, sd
, df
, 9999999.DF
, 9999999., 0.)
60 CONVERT_VALID (314, df
, sd
, 9999999., 9999999.DF
, 0.DF
)
62 /* An integral value with 15 digits (DBL_DIG) can be converted between
63 double and _Decimal64 in both directions. */
64 CONVERT_VALID (321, dd
, df
, 100000000000000.DD
, 100000000000000., 0.)
65 CONVERT_VALID (322, df
, dd
, 100000000000000., 100000000000000.DD
, 0.DD
);
66 CONVERT_VALID (323, dd
, df
, 999999999999999.DD
, 999999999999999., 0.);
67 CONVERT_VALID (324, df
, dd
, 999999999999999., 999999999999999.DD
, 0.DD
);
69 /* If LDBL_DIG is at least 16, an integral value with 16 digits can be
70 converted between _Decimal64 and long double in both directions. */
71 CONVERT_VALID (331, dd
, tf
, 1000000000000000.DD
, 1000000000000000.L
, 0.L
)
72 CONVERT_VALID (332, td
, dd
, 1000000000000000.L
, 1000000000000000.DD
, 0.DD
)
73 CONVERT_VALID (333, dd
, tf
, 9999999999999999.DD
, 9999999999999999.L
, 0.L
)
74 CONVERT_VALID (334, td
, dd
, 9999999999999999.L
, 9999999999999999.DD
, 0.DD
)
76 /* If LDBL_DIG is at least 18, an integral value with 18 digits can be
77 converted between long double and _Decimal128 in both directions. */
78 CONVERT_VALID (341, td
, tf
, 100000000000000000.DL
, 100000000000000000.L
, 0.L
)
79 CONVERT_VALID (342, tf
, td
, 100000000000000000.L
, 100000000000000000.DL
, 0.DL
)
80 CONVERT_VALID (343, td
, tf
, 999999999999999999.DL
, 999999999999999999.L
, 0.L
)
81 CONVERT_VALID (344, tf
, td
, 999999999999999999.L
, 999999999999999999.DL
, 0.DL
)
83 /* If LDBL_DIG is at least 31, an integral value with 31 digits can be
84 converted between long double and _Decimal128 in both directions. */
85 CONVERT_VALID (351, td
, tf
, 1000000000000000000000000000000.DL
,
86 1000000000000000000000000000000.L
, 0.L
)
87 CONVERT_VALID (352, tf
, td
, 1000000000000000000000000000000.L
,
88 1000000000000000000000000000000.DL
, 0.DL
)
89 CONVERT_VALID (353, td
, tf
, 9999999999999999999999999999999.DL
,
90 9999999999999999999999999999999.L
, 0.L
)
91 CONVERT_VALID (354, tf
, td
, 9999999999999999999999999999999.L
,
92 9999999999999999999999999999999.DL
, 0.DL
)
94 /* If LDBL_DIG is at least 33, an integral value with 33 digits can be
95 converted between long double and _Decimal128 in both directions. */
96 CONVERT_VALID (361, td
, tf
, 100000000000000000000000000000000.DL
,
97 100000000000000000000000000000000.L
, 0.L
)
98 CONVERT_VALID (362, tf
, td
, 100000000000000000000000000000000.L
,
99 100000000000000000000000000000000.DL
, 0.DL
)
100 CONVERT_VALID (363, td
, tf
, 999999999999999999999999999999999.DL
,
101 999999999999999999999999999999999.L
, 0.L
)
102 CONVERT_VALID (364, tf
, td
, 999999999999999999999999999999999.L
,
103 999999999999999999999999999999999.DL
, 0.DL
)