1 /* { dg-require-effective-target dfp } */
2
3 /* We need the long double type to be IBM 128-bit because the CONVERT_TO_PINF
4 tests will fail if we use IEEE 128-bit floating point. This is due to IEEE
5 128-bit having a larger exponent range than IBM 128-bit extended double. So
6 tests that would generate an infinity with IBM 128-bit will generate a
7 normal number with IEEE 128-bit. */
8
9 /* { dg-require-effective-target long_double_ibm128 } */
10 /* { dg-options "-O2" } */
11 /* { dg-add-options long_double_ibm128 } */
12
13 /* Test decimal float conversions to and from IBM 128-bit long double. */
14
15 #include "convert.h"
16
17 volatile _Decimal32 sd;
18 volatile _Decimal64 dd;
19 volatile _Decimal128 td;
20 volatile float sf;
21 volatile double df;
22 volatile long double tf;
23
24 /* A value slightly less than DEC32_MAX can be converted in both directions. */
25 CONVERT_VALID (101, sd, tf, 9.999998e96df, 9.999998e96L, 1.e+81L)
26 CONVERT_VALID (102, tf, sd, 9.999998e96L, 9.999998e96df, 0.df)
27
28 /* A value slightly less than DBL_MAX can be converted in both directions. */
29 CONVERT_VALID (201, tf, dd, 1.79768e+308l, 1.79768e+308dd, 0.dd)
30 CONVERT_VALID (202, dd, tf, 1.79768e+308dd, 1.79768e+308l, 2.e292l)
31 CONVERT_VALID (203, tf, td, 1.79768e+308l, 1.79768e+308dl, 1.e292dl)
32 CONVERT_VALID (204, td, tf, 1.79768e+308dl, 1.79768e+308l, 2.e292l)
33
34 /* Check values that are too large for the result type. */
35 CONVERT_TO_PINF (301, dd, tf, 1.8e+308dd, l)
36 CONVERT_TO_PINF (302, dd, tf, 9.9e+384dd, l)
37 CONVERT_TO_PINF (303, td, tf, 1.8e+308dl, l)
38 CONVERT_TO_PINF (304, td, tf, 9.9e+384dl, l)
39
40 CONVERT_TO_PINF (311, tf, sd, 1.0e+97L, d32)
41 CONVERT_TO_PINF (312, tf, sd, 1.6e+308L, d32)
42
43 int
main()44 main ()
45 {
46 convert_101 ();
47 convert_102 ();
48
49 convert_201 ();
50 convert_202 ();
51 convert_203 ();
52 convert_204 ();
53
54 convert_301 ();
55 convert_302 ();
56 convert_303 ();
57 convert_304 ();
58 convert_311 ();
59 convert_312 ();
60
61 FINISH
62 }
63