OSDN Git Service

PR testsuite/41288
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / dfp / convert-bfp-6.c
1 /* { dg-xfail-run-if "" { lax_strtofp } "*" "" } */
2 /* { dg-options "-w" } */
3
4 /* This test assumes IEEE float and double.  */
5
6 #define __STDC_WANT_DEC_FP__
7 #include <float.h>
8
9 #include "convert.h"
10
11 volatile _Decimal32 sd;
12 volatile _Decimal64 dd;
13 volatile _Decimal128 td;
14 volatile float sf;
15 volatile double df;
16 volatile long double tf;
17
18 CONVERT_VALID (101, td, sf, 0.000488281251dl, 0.00048828125f, 0.f)
19
20 /* 2**(-25) = 0.298023223876953125E-7.  */
21 CONVERT_VALID (102, td, sf, 2.98023223876953125e-8dl, 2.9802322387695312e-08f,
22                01.e-13f)
23
24 /* Fractional part doesn't fit.  */
25 CONVERT_VALID (103, df, sd, 1.0e-20, 1.0e-20df, 0.df)
26
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)
30
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)
38
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)
42
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.)
48
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)
55
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)
62
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);
69
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)
76
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)
83
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)
94
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)
105
106 int
107 main ()
108 {
109   convert_101 ();
110   convert_102 ();
111   convert_103 ();
112   convert_104 ();
113   convert_105 ();
114
115   convert_201 ();
116   convert_202 ();
117   convert_203 ();
118   convert_204 ();
119   convert_205 ();
120   convert_206 ();
121
122   convert_211 ();
123   convert_212 ();
124
125   convert_221 ();
126   convert_222 ();
127   convert_223 ();
128   convert_224 ();
129
130   convert_301 ();
131   convert_302 ();
132   convert_303 ();
133   convert_304 ();
134
135   convert_311 ();
136   convert_312 ();
137   convert_313 ();
138   convert_314 ();
139
140   convert_321 ();
141   convert_322 ();
142   convert_323 ();
143   convert_324 ();
144
145   if (LDBL_DIG >= 16)
146     {
147       convert_331 ();
148       convert_332 ();
149       convert_333 ();
150       convert_334 ();
151     }
152
153   if (LDBL_DIG >= 18)
154     {
155       convert_341 ();
156       convert_342 ();
157       convert_343 ();
158       convert_344 ();
159     }
160
161   if (LDBL_DIG >= 31)
162     {
163       convert_351 ();
164       convert_352 ();
165       convert_353 ();
166       convert_354 ();
167     }
168
169   if (LDBL_DIG >= 33)
170     {
171       convert_361 ();
172       convert_362 ();
173       convert_363 ();
174       convert_364 ();
175     }
176
177   FINISH
178 }