1 // Copyright (C) 2009 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // { dg-require-effective-target dfp }
20 // ISO/IEC TR 24733 3.2.6 Conversion to generic floating-point type.
22 #include <decimal/decimal>
23 #include <testsuite_hooks.h>
25 using namespace std::decimal;
28 conversion_to_generic_float_32 ()
30 std::decimal::decimal32 d32(123);
35 f = decimal32_to_float (d32);
37 d = decimal32_to_double (d32);
39 ld = decimal32_to_long_double (d32);
43 f = decimal_to_float (d32);
45 d = decimal_to_double (d32);
47 ld = decimal_to_long_double (d32);
52 conversion_to_generic_float_64 ()
54 std::decimal::decimal64 d64(234);
59 f = decimal64_to_float (d64);
61 d = decimal64_to_double (d64);
63 ld = decimal64_to_long_double (d64);
67 f = decimal_to_float (d64);
69 d = decimal_to_double (d64);
71 ld = decimal_to_long_double (d64);
76 conversion_to_generic_float_128 ()
78 std::decimal::decimal128 d128(345);
83 f = decimal128_to_float (d128);
85 d = decimal128_to_double (d128);
87 ld = decimal128_to_long_double (d128);
91 f = decimal_to_float (d128);
93 d = decimal_to_double (d128);
95 ld = decimal_to_long_double (d128);
102 conversion_to_generic_float_32 ();
103 conversion_to_generic_float_64 ();
104 conversion_to_generic_float_128 ();