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