2015-10-17 Steven G. Kargl <kargl@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / c-c++-common / dfp / convert-bfp-11.c
blobd16919f81ac9a2da33fcb3922fa7fc559a041ba9
1 /* { dg-skip-if "" { ! "powerpc*-*-linux*" } { "*" } { "" } } */
3 /* Test decimal float conversions to and from IBM 128-bit long double.
4 Checks are skipped at runtime if long double is not 128 bits.
5 Don't force 128-bit long doubles because runtime support depends
6 on glibc. */
8 #include "convert.h"
10 volatile _Decimal32 sd;
11 volatile _Decimal64 dd;
12 volatile _Decimal128 td;
13 volatile float sf;
14 volatile double df;
15 volatile long double tf;
17 /* A value slightly less than DEC32_MAX can be converted in both directions. */
18 CONVERT_VALID (101, sd, tf, 9.999998e96df, 9.999998e96L, 1.e+81L)
19 CONVERT_VALID (102, tf, sd, 9.999998e96L, 9.999998e96df, 0.df)
21 /* A value slightly less than DBL_MAX can be converted in both directions. */
22 CONVERT_VALID (201, tf, dd, 1.79768e+308l, 1.79768e+308dd, 0.dd)
23 CONVERT_VALID (202, dd, tf, 1.79768e+308dd, 1.79768e+308l, 2.e292l)
24 CONVERT_VALID (203, tf, td, 1.79768e+308l, 1.79768e+308dl, 1.e292dl)
25 CONVERT_VALID (204, td, tf, 1.79768e+308dl, 1.79768e+308l, 2.e292l)
27 /* Check values that are too large for the result type. */
28 CONVERT_TO_PINF (301, dd, tf, 1.8e+308dd, l)
29 CONVERT_TO_PINF (302, dd, tf, 9.9e+384dd, l)
30 CONVERT_TO_PINF (303, td, tf, 1.8e+308dl, l)
31 CONVERT_TO_PINF (304, td, tf, 9.9e+384dl, l)
33 CONVERT_TO_PINF (311, tf, sd, 1.0e+97L, d32)
34 CONVERT_TO_PINF (312, tf, sd, 1.6e+308L, d32)
36 int
37 main ()
39 if (sizeof (long double) != 16)
40 return 0;
42 convert_101 ();
43 convert_102 ();
45 convert_201 ();
46 convert_202 ();
47 convert_203 ();
48 convert_204 ();
50 convert_301 ();
51 convert_302 ();
52 convert_303 ();
53 convert_304 ();
54 convert_311 ();
55 convert_312 ();
57 FINISH