[multiple changes]

2009-10-05  Benjamin Kosnik  <bkoz@redhat.com>
	    Edward Smith-Rowland  <3dw4rd@verizon.net>

	* include/decimal/decimal: Warn if decimal floating point types
	are not available.
	* acinclude.m4 (GLIBCXX_ENABLE_DECIMAL_FLOAT): New.
	* configure.ac: Use it.
	* configure: Regenerate.
	* config.h.in: Regenerate.

2009-10-05  Benjamin Kosnik  <bkoz@redhat.com>

	* include/Makefile.am: Remove stray line break.

	* include/decimal/decimal: Brief class doxygen markup.
	* libsupc++/exception: Whitespace cleanup.

	* testsuite/libstdc++-dg/conformance.exp: Add testsuite directory
	decimal.
	* scripts/create_testsuite_files (dlist): Same.

	* doc/xml/manual/using.xml: One column in table. Move after TR1.

	* testsuite/decimal/bad-cast.cc: Move to...
	* testsuite/decimal/cast_neg.cc: ...here.
	* testsuite/decimal/bad-mixed-mode.cc: Move to...
	* testsuite/decimal/mixed-mode_neg.cc: ...here.
	* testsuite/decimal/bad-operator.cc: Move to...
	* testsuite/decimal/operator_neg.cc: ...here.

	* doc/doxygen/user.cfg.in (INPUT): Add decimal/decimal.

2009-10-05  Janis Johnson  <janis187@us.ibm.com>

	* doc/Makefile.am: Process new file.
	* doc/xml/manual/intro.xml: Ditto.
	* doc/xml/manual/using.xml: Document new header.
	* doc/xml/manual/status_cxxdecimal.xml: New file.
	* include/Makefile.am: Process new headers.
	* include/decimal/decimal: New file.
	* include/decimal/decimal.h: New file.

2009-10-05  Janis Johnson  <janis187@us.ibm.com>

	* testsuite/decimal: New directory.
	* testsuite/decimal/bad-cast.cc: New test.
	* testsuite/decimal/bad-mixed-mode.cc: New test.
	* testsuite/decimal/bad-operator.cc: New test.
	* testsuite/decimal/binary-arith.cc: New test.
	* testsuite/decimal/comparison.cc: New test.
	* testsuite/decimal/compound-assignment.cc: New test.
	* testsuite/decimal/compound-assignment-memfunc.cc: New test.
	* testsuite/decimal/conversion-from-float.cc: New test.
	* testsuite/decimal/conversion-from-integral.cc: New test.
	* testsuite/decimal/conversion-to-generic-float.cc: New test.
	* testsuite/decimal/conversion-to-integral.cc: New test.
	* testsuite/decimal/ctor.cc: New test.
	* testsuite/decimal/incdec.cc: New test.
	* testsuite/decimal/incdec-memfunc.cc: New test.
	* testsuite/decimal/make-decimal.cc: New test.
	* testsuite/decimal/unary-arith.cc: New test.

From-SVN: r152457
This commit is contained in:
Benjamin Kosnik 2009-10-05 17:42:00 +00:00
parent 8fc7e474ff
commit 4cdc876153
35 changed files with 4511 additions and 39 deletions

View File

@ -1,3 +1,65 @@
2009-10-05 Benjamin Kosnik <bkoz@redhat.com>
Edward Smith-Rowland <3dw4rd@verizon.net>
* include/decimal/decimal: Warn if decimal floating point types
are not available.
* acinclude.m4 (GLIBCXX_ENABLE_DECIMAL_FLOAT): New.
* configure.ac: Use it.
* configure: Regenerate.
* config.h.in: Regenerate.
2009-10-05 Benjamin Kosnik <bkoz@redhat.com>
* include/Makefile.am: Remove stray line break.
* include/decimal/decimal: Brief class doxygen markup.
* libsupc++/exception: Whitespace cleanup.
* testsuite/libstdc++-dg/conformance.exp: Add testsuite directory
decimal.
* scripts/create_testsuite_files (dlist): Same.
* doc/xml/manual/using.xml: One column in table. Move after TR1.
* testsuite/decimal/bad-cast.cc: Move to...
* testsuite/decimal/cast_neg.cc: ...here.
* testsuite/decimal/bad-mixed-mode.cc: Move to...
* testsuite/decimal/mixed-mode_neg.cc: ...here.
* testsuite/decimal/bad-operator.cc: Move to...
* testsuite/decimal/operator_neg.cc: ...here.
* doc/doxygen/user.cfg.in (INPUT): Add decimal/decimal.
2009-10-05 Janis Johnson <janis187@us.ibm.com>
* doc/Makefile.am: Process new file.
* doc/xml/manual/intro.xml: Ditto.
* doc/xml/manual/using.xml: Document new header.
* doc/xml/manual/status_cxxdecimal.xml: New file.
* include/Makefile.am: Process new headers.
* include/decimal/decimal: New file.
* include/decimal/decimal.h: New file.
2009-10-05 Janis Johnson <janis187@us.ibm.com>
* testsuite/decimal: New directory.
* testsuite/decimal/bad-cast.cc: New test.
* testsuite/decimal/bad-mixed-mode.cc: New test.
* testsuite/decimal/bad-operator.cc: New test.
* testsuite/decimal/binary-arith.cc: New test.
* testsuite/decimal/comparison.cc: New test.
* testsuite/decimal/compound-assignment.cc: New test.
* testsuite/decimal/compound-assignment-memfunc.cc: New test.
* testsuite/decimal/conversion-from-float.cc: New test.
* testsuite/decimal/conversion-from-integral.cc: New test.
* testsuite/decimal/conversion-to-generic-float.cc: New test.
* testsuite/decimal/conversion-to-integral.cc: New test.
* testsuite/decimal/ctor.cc: New test.
* testsuite/decimal/incdec.cc: New test.
* testsuite/decimal/incdec-memfunc.cc: New test.
* testsuite/decimal/make-decimal.cc: New test.
* testsuite/decimal/unary-arith.cc: New test.
2009-10-05 Paolo Carlini <paolo.carlini@oracle.com>
* testsuite/lib/libstdc++.exp (check_v3_target_rvalref): Remove.

View File

@ -2221,6 +2221,44 @@ AC_DEFUN([GLIBCXX_ENABLE_LONG_LONG], [
])
dnl
dnl Check for decimal floating point.
dnl See:
dnl http://gcc.gnu.org/onlinedocs/gcc/Decimal-Float.html#Decimal-Float
dnl
dnl This checks to see if the host supports decimal floating point types.
dnl
dnl Defines:
dnl _GLIBCXX_USE_DECIMAL_FLOAT
dnl
AC_DEFUN([GLIBCXX_ENABLE_DECIMAL_FLOAT], [
# Fake what AC_TRY_COMPILE does, without linking as this is
# unnecessary for this test.
cat > conftest.$ac_ext << EOF
[#]line __oline__ "configure"
int main()
{
_Decimal32 d1;
_Decimal64 d2;
_Decimal128 d3;
return 0;
}
EOF
AC_MSG_CHECKING([for ISO/IEC TR 24733 ])
if AC_TRY_EVAL(ac_compile); then
AC_DEFINE(_GLIBCXX_USE_DECIMAL_FLOAT, 1,
[Define if ISO/IEC TR 24733 decimal floating point types are supported on this host.])
enable_dfp=yes
else
enable_dfp=no
fi
AC_MSG_RESULT($enable_dfp)
rm -f conftest*
])
dnl
dnl Check for template specializations for the 'wchar_t' type.
dnl

View File

@ -262,9 +262,6 @@
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the <execinfo.h> header file. */
#undef HAVE_EXECINFO_H
/* Define to 1 if you have the `modf' function. */
#undef HAVE_MODF
@ -772,6 +769,10 @@
/* Defined if clock_gettime has realtime clock support. */
#undef _GLIBCXX_USE_CLOCK_REALTIME
/* Define if ISO/IEC TR 24733 decimal floating point types are supported on
this host. */
#undef _GLIBCXX_USE_DECIMAL_FLOAT
/* Defined if gettimeofday is available. */
#undef _GLIBCXX_USE_GETTIMEOFDAY

View File

@ -7926,7 +7926,7 @@ fi
# On IRIX 5.3, sys/types and inttypes.h are conflicting.
for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
inttypes.h stdint.h unistd.h execinfo.h
inttypes.h stdint.h unistd.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
@ -15358,6 +15358,40 @@ $as_echo "$as_me: WARNING: Performance of certain classes will degrade as a resu
# Fake what AC_TRY_COMPILE does, without linking as this is
# unnecessary for this test.
cat > conftest.$ac_ext << EOF
#line 15366 "configure"
int main()
{
_Decimal32 d1;
_Decimal64 d2;
_Decimal128 d3;
return 0;
}
EOF
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ISO/IEC TR 24733 " >&5
$as_echo_n "checking for ISO/IEC TR 24733 ... " >&6; }
if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
(eval $ac_compile) 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
$as_echo "#define _GLIBCXX_USE_DECIMAL_FLOAT 1" >>confdefs.h
enable_dfp=yes
else
enable_dfp=no
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_dfp" >&5
$as_echo "$enable_dfp" >&6; }
rm -f conftest*
# Checks for compiler support that doesn't require linking.
# All these tests are for C++; save the language and the compiler flags.

View File

@ -128,6 +128,7 @@ GLIBCXX_ENABLE_SJLJ_EXCEPTIONS
GLIBCXX_ENABLE_PCH($is_hosted)
GLIBCXX_ENABLE_THREADS
GLIBCXX_ENABLE_ATOMIC_BUILTINS
GLIBCXX_ENABLE_DECIMAL_FLOAT
# Checks for compiler support that doesn't require linking.
GLIBCXX_CHECK_COMPILER_FEATURES

View File

@ -107,6 +107,7 @@ xml_sources = \
${xml_srcdir}/manual/status_cxx1998.xml \
${xml_srcdir}/manual/status_cxx200x.xml \
${xml_srcdir}/manual/status_cxxtr1.xml \
${xml_srcdir}/manual/status_cxxtr24733.xml \
${xml_srcdir}/manual/strings.xml \
${xml_srcdir}/manual/support.xml \
${xml_srcdir}/manual/test.xml \

View File

@ -319,6 +319,7 @@ xml_sources = \
${xml_srcdir}/manual/status_cxx1998.xml \
${xml_srcdir}/manual/status_cxx200x.xml \
${xml_srcdir}/manual/status_cxxtr1.xml \
${xml_srcdir}/manual/status_cxxtr24733.xml \
${xml_srcdir}/manual/strings.xml \
${xml_srcdir}/manual/support.xml \
${xml_srcdir}/manual/test.xml \

View File

@ -727,6 +727,7 @@ INPUT = @srcdir@/doc/doxygen/doxygroups.cc \
include/tr1_impl/unordered_set \
include/tr1_impl/utility \
include/tr1_impl \
include/decimal/decimal \
include/ \
include/@host_alias@/bits \
include/backward \

View File

@ -44,6 +44,11 @@
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
parse="xml" href="status_cxx200x.xml">
</xi:include>
<!-- Section 01.4 : Status C++ TR24733 -->
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
parse="xml" href="status_cxxtr24733.xml">
</xi:include>
</sect1>
<!-- Section 02 : License -->

View File

@ -0,0 +1,299 @@
<sect2 id="status.iso.tr24733" xreflabel="Status C++ TR24733">
<?dbhtml filename="status_iso_cxxtr24733.html"?>
<sect2info>
<keywordset>
<keyword>
TR 24733
</keyword>
</keywordset>
</sect2info>
<title>C++ TR 24733</title>
<para>
This table is based on the table of contents of
ISO/IEC TR 24733 Date: 2009-08-28
Extension for the programming language C++ to support
decimal floating-point arithmetic
</para>
<para>
This page describes the TR 24733 support in mainline GCC SVN, not in any
particular release.
</para>
<!-- Status is Yes or No, Broken/Partial-->
<!--
Yes
No
<?dbhtml bgcolor="#C8B0B0" ?>
Broken/Partial
<?dbhtml bgcolor="#B0B0B0" ?>
-->
<table frame='all'>
<title>C++ TR 24733 Implementation Status</title>
<tgroup cols='4' align='left' colsep='0' rowsep='1'>
<colspec colname='c1'></colspec>
<colspec colname='c2'></colspec>
<colspec colname='c3'></colspec>
<colspec colname='c4'></colspec>
<thead>
<row>
<entry>Section</entry>
<entry>Description</entry>
<entry>Status</entry>
<entry>Comments</entry>
</row>
</thead>
<tbody>
<row>
<entry>
<emphasis>0</emphasis>
</entry>
<entry namest="c2" nameend="c4" align="left">
<emphasis>Introduction</emphasis>
</entry>
</row>
<row>
<entry>
<emphasis>1</emphasis>
</entry>
<entry namest="c2" nameend="c4" align="left">
<emphasis>Normative references</emphasis>
</entry>
</row>
<row>
<entry>
<emphasis>2</emphasis>
</entry>
<entry namest="c2" nameend="c4" align="left">
<emphasis>Conventions</emphasis>
</entry>
</row>
<row>
<entry>
<emphasis>3</emphasis>
</entry>
<entry namest="c2" nameend="c4" align="left">
<emphasis>Decimal floating-point types</emphasis>
</entry>
</row>
<row>
<entry>3.1</entry>
<entry>Characteristics of decimal floating-point types</entry>
<entry></entry>
<entry></entry>
</row>
<row>
<entry>3.2</entry>
<entry>Decimal Types</entry>
<entry></entry>
<entry></entry>
</row>
<row>
<?dbhtml bgcolor="#B0B0B0" ?>
<entry>3.2.1</entry>
<entry>Class <code>decimal</code> synopsis</entry>
<entry>Partial</entry>
<entry>Missing declarations for formatted input/output; non-conforming extension for functions converting to integral type</entry>
</row>
<row>
<?dbhtml bgcolor="#B0B0B0" ?>
<entry>3.2.2</entry>
<entry>Class <code>decimal32</code></entry>
<entry>Partial</entry>
<entry>Missing 3.2.2.5 conversion to integral type; conforming extension for conversion from scalar decimal floating-point</entry>
</row>
<row>
<?dbhtml bgcolor="#B0B0B0" ?>
<entry>3.2.3</entry>
<entry>Class <code>decimal64</code></entry>
<entry>Partial</entry>
<entry>Missing 3.2.3.5 conversion to integral type; conforming extension for conversion from scalar decimal floating-point</entry>
</row>
<row>
<?dbhtml bgcolor="#B0B0B0" ?>
<entry>3.2.4</entry>
<entry>Class <code>decimal128</code></entry>
<entry>Partial</entry>
<entry>Missing 3.2.4.5 conversion to integral type; conforming extension for conversion from scalar decimal floating-point</entry>
</row>
<row>
<entry>3.2.5</entry>
<entry>Initialization from coefficient and exponent</entry>
<entry>Y</entry>
<entry></entry>
</row>
<row>
<entry>3.2.6</entry>
<entry>Conversion to generic floating-point type</entry>
<entry>Y</entry>
<entry></entry>
</row>
<row>
<entry>3.2.7</entry>
<entry>Unary arithmetic operators</entry>
<entry>Y</entry>
<entry></entry>
</row>
<row>
<entry>3.2.8</entry>
<entry>Binary arithmetic operators</entry>
<entry>Y</entry>
<entry></entry>
</row>
<row>
<entry>3.2.9</entry>
<entry>Comparison operators</entry>
<entry>Y</entry>
<entry></entry>
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry>3.2.10</entry>
<entry>Formatted input</entry>
<entry>N</entry>
<entry></entry>
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry>3.2.11</entry>
<entry>Formatted output</entry>
<entry>N</entry>
<entry></entry>
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry>3.3</entry>
<entry>Additions to header <code>limits</code></entry>
<entry>N</entry>
<entry></entry>
</row>
<row>
<entry>3.4</entry>
<entry>Headers <code>cfloat</code> and <code>float.h</code></entry>
<entry></entry>
<entry></entry>
</row>
<row>
<entry>3.4.2</entry>
<entry>Additions to header <code>cfloat</code> synopsis</entry>
<entry>Y</entry>
<entry></entry>
</row>
<row>
<?dbhtml bgcolor="#B0B0B0" ?>
<entry>3.4.3</entry>
<entry>Additions to header <code>float.h</code> synopsis</entry>
<entry>N</entry>
<entry></entry>
</row>
<row>
<entry>3.4.4</entry>
<entry>Maximum finite value</entry>
<entry>Y</entry>
<entry></entry>
</row>
<row>
<entry>3.4.5</entry>
<entry>Epsilon</entry>
<entry>Y</entry>
<entry></entry>
</row>
<row>
<entry>3.4.6</entry>
<entry>Minimum positive normal value</entry>
<entry>Y</entry>
<entry></entry>
</row>
<row>
<entry>3.4.7</entry>
<entry>Minimum positive subnormal value</entry>
<entry>Y</entry>
<entry></entry>
</row>
<row>
<entry>3.4.8</entry>
<entry>Evaluation format</entry>
<entry>Y</entry>
<entry></entry>
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry>3.5</entry>
<entry>Additions to <code>cfenv</code> and <code>fenv.h</code></entry>
<entry>Outside the scope of GCC</entry>
<entry></entry>
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry>3.6</entry>
<entry>Additions to <code>cmath</code> and <code>math.h</code></entry>
<entry>Outside the scope of GCC</entry>
<entry></entry>
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry>3.7</entry>
<entry>Additions to <code>cstdio</code> and <code>stdio.h</code></entry>
<entry>Outside the scope of GCC</entry>
<entry></entry>
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry>3.8</entry>
<entry>Additions to <code>cstdlib</code> and <code>stdlib.h</code></entry>
<entry>Outside the scope of GCC</entry>
<entry></entry>
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry>3.9</entry>
<entry>Additions to <code>cwchar</code> and <code>wchar.h</code></entry>
<entry>Outside the scope of GCC</entry>
<entry></entry>
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry>3.10</entry>
<entry>Facets</entry>
<entry>N</entry>
<entry></entry>
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry>3.11</entry>
<entry>Type traits</entry>
<entry>N</entry>
<entry></entry>
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry>3.12</entry>
<entry>Hash functions</entry>
<entry>N</entry>
<entry></entry>
</row>
<row>
<entry>
<emphasis>4</emphasis>
</entry>
<entry namest="c2" nameend="c4" align="left">
<emphasis>Notes on C compatibility</emphasis>
</entry>
</row>
</tbody>
</tgroup>
</table>
</sect2>

View File

@ -360,7 +360,7 @@ mode, i.e. <literal>-std=c++0x</literal> or <literal>-std=gnu++0x</literal>.
</para>
<table frame='all'>
<title>C++ TR1 Library Headers</title>
<title>C++ TR 1 Library Headers</title>
<tgroup cols='5' align='left' colsep='1' rowsep='1'>
<colspec colname='c1'></colspec>
<colspec colname='c2'></colspec>
@ -395,7 +395,7 @@ mode, i.e. <literal>-std=c++0x</literal> or <literal>-std=gnu++0x</literal>.
<table frame='all'>
<title>C++ TR1 Library Headers for C Library Facilities</title>
<title>C++ TR 1 Library Headers for C Library Facilities</title>
<tgroup cols='5' align='left' colsep='1' rowsep='1'>
<colspec colname='c1'></colspec>
<colspec colname='c2'></colspec>
@ -430,6 +430,24 @@ mode, i.e. <literal>-std=c++0x</literal> or <literal>-std=gnu++0x</literal>.
</tgroup>
</table>
<para>Decimal floating-point arithmetic is available if the C++
compiler supports scalar decimal floating-point types defined via
<code>__attribute__((mode(SD|DD|LD)))</code>.
</para>
<table frame='all'>
<title>C++ TR 24733 Decimal Floating-Point Header</title>
<tgroup cols='1' align='left' colsep='1' rowsep='1'>
<colspec colname='c1'></colspec>
<tbody>
<row>
<entry><filename class="headerfile">decimal/decimal</filename></entry>
</row>
</tbody>
</tgroup>
</table>
<para>
Also included are files for the C++ ABI interface:
</para>

View File

@ -618,6 +618,11 @@ tr1_impl_headers = \
${tr1_impl_srcdir}/unordered_set \
${tr1_impl_srcdir}/utility
decimal_srcdir = ${glibcxx_srcdir}/include/decimal
decimal_builddir = ./decimal
decimal_headers = \
${decimal_srcdir}/decimal \
${decimal_srcdir}/decimal.h
# This is the common subset of C++ files that all three "C" header models use.
c_base_srcdir = $(C_INCLUDE_DIR)
@ -896,8 +901,8 @@ endif
allstamped = \
stamp-std stamp-bits stamp-c_base stamp-c_base_extra \
stamp-c_compatibility stamp-backward stamp-ext stamp-pb \
stamp-tr1 stamp-tr1-impl stamp-debug stamp-parallel stamp-host \
stamp-profile stamp-profile-impl
stamp-tr1 stamp-tr1-impl stamp-decimal stamp-debug \
stamp-parallel stamp-profile stamp-profile-impl stamp-host
# List of all files that are created by explicit building, editing, or
# catenation.
@ -1011,6 +1016,11 @@ stamp-tr1-impl: ${tr1_impl_headers}
@-cd ${tr1_impl_builddir} && $(LN_S) $? . 2>/dev/null
@$(STAMP) stamp-tr1-impl
stamp-decimal: ${decimal_headers}
@-mkdir -p ${decimal_builddir}
@-cd ${decimal_builddir} && $(LN_S) $? . 2>/dev/null
@$(STAMP) stamp-decimal
stamp-debug: ${debug_headers}
@-mkdir -p ${debug_builddir}
@-cd ${debug_builddir} && $(LN_S) $? . 2>/dev/null
@ -1239,6 +1249,9 @@ install-headers:
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${tr1_impl_builddir}
for file in ${tr1_impl_headers}; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${tr1_impl_builddir}; done
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${decimal_builddir}
for file in ${decimal_headers}; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${decimal_builddir}; done
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${c_base_builddir}
for file in ${c_base_headers}; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${c_base_builddir}; done
@ -1283,9 +1296,10 @@ clean-local:
# directory. (This is more of an example of how this kind of rule can
# be made.)
.PRECIOUS: $(std_headers) $(c_base_headers) $(tr1_headers) $(tr1_impl_headers)
$(ext_headers)
$(decimal_headers) $(ext_headers)
$(std_headers): ; @:
$(c_base_headers): ; @:
$(tr1_headers): ; @:
$(tr1_impl_headers): ; @:
$(decimal_headers): ; @:
$(ext_headers): ; @:

View File

@ -14,6 +14,8 @@
# PARTICULAR PURPOSE.
@SET_MAKE@
#o# Makefile for the include subdirectory of the GNU C++ Standard library.
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
@ -856,6 +858,12 @@ tr1_impl_headers = \
${tr1_impl_srcdir}/unordered_set \
${tr1_impl_srcdir}/utility
decimal_srcdir = ${glibcxx_srcdir}/include/decimal
decimal_builddir = ./decimal
decimal_headers = \
${decimal_srcdir}/decimal \
${decimal_srcdir}/decimal.h
# This is the common subset of C++ files that all three "C" header models use.
c_base_srcdir = $(C_INCLUDE_DIR)
@ -1006,20 +1014,21 @@ parallel_builddir = ./parallel
profile_srcdir = ${glibcxx_srcdir}/include/profile
profile_builddir = ./profile
profile_headers = \
${profile_srcdir}/base.h \
${profile_srcdir}/unordered_map \
${profile_srcdir}/unordered_set \
${profile_srcdir}/vector \
${profile_srcdir}/bitset \
${profile_srcdir}/deque \
${profile_srcdir}/list \
${profile_srcdir}/map \
${profile_srcdir}/map.h \
${profile_srcdir}/multimap.h \
${profile_srcdir}/multiset.h \
${profile_srcdir}/set \
${profile_srcdir}/set.h \
${profile_srcdir}/hashtable.h
${profile_srcdir}/base.h \
${profile_srcdir}/unordered_map \
${profile_srcdir}/unordered_set \
${profile_srcdir}/vector \
${profile_srcdir}/bitset \
${profile_srcdir}/deque \
${profile_srcdir}/list \
${profile_srcdir}/map \
${profile_srcdir}/map.h \
${profile_srcdir}/multimap.h \
${profile_srcdir}/multiset.h \
${profile_srcdir}/set \
${profile_srcdir}/set.h \
${profile_srcdir}/hashtable.h
profile_impl_srcdir = ${glibcxx_srcdir}/include/profile/impl
profile_impl_builddir = ./profile/impl
profile_impl_headers = \
@ -1116,8 +1125,8 @@ PCHFLAGS = -x c++-header $(CXXFLAGS)
allstamped = \
stamp-std stamp-bits stamp-c_base stamp-c_base_extra \
stamp-c_compatibility stamp-backward stamp-ext stamp-pb \
stamp-tr1 stamp-tr1-impl stamp-debug stamp-parallel stamp-host \
stamp-profile stamp-profile-impl
stamp-tr1 stamp-tr1-impl stamp-decimal stamp-debug \
stamp-parallel stamp-profile stamp-profile-impl stamp-host
# List of all files that are created by explicit building, editing, or
@ -1424,6 +1433,11 @@ stamp-tr1-impl: ${tr1_impl_headers}
@-cd ${tr1_impl_builddir} && $(LN_S) $? . 2>/dev/null
@$(STAMP) stamp-tr1-impl
stamp-decimal: ${decimal_headers}
@-mkdir -p ${decimal_builddir}
@-cd ${decimal_builddir} && $(LN_S) $? . 2>/dev/null
@$(STAMP) stamp-decimal
stamp-debug: ${debug_headers}
@-mkdir -p ${debug_builddir}
@-cd ${debug_builddir} && $(LN_S) $? . 2>/dev/null
@ -1640,6 +1654,9 @@ install-headers:
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${tr1_impl_builddir}
for file in ${tr1_impl_headers}; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${tr1_impl_builddir}; done
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${decimal_builddir}
for file in ${decimal_headers}; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${decimal_builddir}; done
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${c_base_builddir}
for file in ${c_base_headers}; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${c_base_builddir}; done
@ -1660,8 +1677,7 @@ install-headers:
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${parallel_builddir};\
for file in $$parallel_headers_install; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${parallel_builddir}; done
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${profile_builddir} \
$(DESTDIR)${gxx_include_dir}/${profile_builddir}/impl
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${profile_builddir}
for file in ${profile_headers}; do \
$(INSTALL_DATA) $${file} $(DESTDIR)${gxx_include_dir}/${profile_builddir}; done
$(mkinstalldirs) $(DESTDIR)${gxx_include_dir}/${profile_impl_builddir}
@ -1682,11 +1698,12 @@ clean-local:
# directory. (This is more of an example of how this kind of rule can
# be made.)
.PRECIOUS: $(std_headers) $(c_base_headers) $(tr1_headers) $(tr1_impl_headers)
$(ext_headers)
$(decimal_headers) $(ext_headers)
$(std_headers): ; @:
$(c_base_headers): ; @:
$(tr1_headers): ; @:
$(tr1_impl_headers): ; @:
$(decimal_headers): ; @:
$(ext_headers): ; @:
# Tell versions [3.59,3.63) of GNU make to not export all variables.

View File

@ -0,0 +1,482 @@
// <decimal> -*- C++ -*-
// Copyright (C) 2009 Free Software Foundation, Inc.
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file include/decimal/decimal
* This is a Standard C++ Library header.
*/
// ISO/IEC TR 24733
// Written by Janis Johnson <janis187@us.ibm.com>
#ifndef _GLIBCXX_DECIMAL
#define _GLIBCXX_DECIMAL 1
#pragma GCC system_header
#include <bits/c++config.h>
#ifndef _GLIBCXX_USE_DECIMAL_FLOAT
#error This file requires compiler and library support for ISO/IEC TR 24733 \
that is currently not available.
#endif
namespace std
{
/**
* @defgroup decimal Decimal Floating-Point Arithmetic
* @ingroup numerics
*
* Classes and functions for decimal floating-point arithmetic.
* @{
*/
/** @namespace std::decimal
* @brief ISO/IEC TR 24733 Decimal floating-point arithmetic.
*/
namespace decimal
{
class decimal32;
class decimal64;
class decimal128;
// 3.2.5 Initialization from coefficient and exponent.
static decimal32 make_decimal32(long long __coeff, int __exp);
static decimal32 make_decimal32(unsigned long long __coeff, int __exp);
static decimal64 make_decimal64(long long __coeff, int __exp);
static decimal64 make_decimal64(unsigned long long __coeff, int __exp);
static decimal128 make_decimal128(long long __coeff, int __exp);
static decimal128 make_decimal128(unsigned long long __coeff, int __exp);
/// Non-conforming extension: Conversion to integral type.
long long decimal32_to_long_long(decimal32 __d);
long long decimal64_to_long_long(decimal64 __d);
long long decimal128_to_long_long(decimal128 __d);
long long decimal_to_long_long(decimal32 __d);
long long decimal_to_long_long(decimal64 __d);
long long decimal_to_long_long(decimal128 __d);
// 3.2.6 Conversion to generic floating-point type.
float decimal32_to_float(decimal32 __d);
float decimal64_to_float(decimal64 __d);
float decimal128_to_float(decimal128 __d);
float decimal_to_float(decimal32 __d);
float decimal_to_float(decimal64 __d);
float decimal_to_float(decimal128 __d);
double decimal32_to_double(decimal32 __d);
double decimal64_to_double(decimal64 __d);
double decimal128_to_double(decimal128 __d);
double decimal_to_double(decimal32 __d);
double decimal_to_double(decimal64 __d);
double decimal_to_double(decimal128 __d);
long double decimal32_to_long_double(decimal32 __d);
long double decimal64_to_long_double(decimal64 __d);
long double decimal128_to_long_double(decimal128 __d);
long double decimal_to_long_double(decimal32 __d);
long double decimal_to_long_double(decimal64 __d);
long double decimal_to_long_double(decimal128 __d);
// 3.2.7 Unary arithmetic operators.
decimal32 operator+(decimal32 __rhs);
decimal64 operator+(decimal64 __rhs);
decimal128 operator+(decimal128 __rhs);
decimal32 operator-(decimal32 __rhs);
decimal64 operator-(decimal64 __rhs);
decimal128 operator-(decimal128 __rhs);
// 3.2.8 Binary arithmetic operators.
#define _DECLARE_DECIMAL_BINARY_OP_WITH_DEC(_Op, _T1, _T2, _T3) \
_T1 operator _Op(_T2 lhs, _T3 __rhs);
#define _DECLARE_DECIMAL_BINARY_OP_WITH_INT(_Op, _Tp) \
_Tp operator _Op(_Tp lhs, int __rhs); \
_Tp operator _Op(_Tp lhs, unsigned int __rhs); \
_Tp operator _Op(_Tp lhs, long __rhs); \
_Tp operator _Op(_Tp lhs, unsigned long __rhs); \
_Tp operator _Op(_Tp lhs, long long __rhs); \
_Tp operator _Op(_Tp lhs, unsigned long long __rhs); \
_Tp operator _Op(int lhs, _Tp __rhs); \
_Tp operator _Op(unsigned int lhs, _Tp __rhs); \
_Tp operator _Op(long lhs, _Tp __rhs); \
_Tp operator _Op(unsigned long lhs, _Tp __rhs); \
_Tp operator _Op(long long lhs, _Tp __rhs); \
_Tp operator _Op(unsigned long long lhs, _Tp __rhs);
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal32, decimal32, decimal32)
_DECLARE_DECIMAL_BINARY_OP_WITH_INT(+, decimal32)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal64, decimal32, decimal64)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal64, decimal64, decimal32)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal64, decimal64, decimal64)
_DECLARE_DECIMAL_BINARY_OP_WITH_INT(+, decimal64)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal32, decimal128)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal64, decimal128)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal128, decimal32)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal128, decimal64)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal128, decimal128)
_DECLARE_DECIMAL_BINARY_OP_WITH_INT(+, decimal128)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal32, decimal32, decimal32)
_DECLARE_DECIMAL_BINARY_OP_WITH_INT(-, decimal32)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal64, decimal32, decimal64)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal64, decimal64, decimal32)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal64, decimal64, decimal64)
_DECLARE_DECIMAL_BINARY_OP_WITH_INT(-, decimal64)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal32, decimal128)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal64, decimal128)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal128, decimal32)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal128, decimal64)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal128, decimal128)
_DECLARE_DECIMAL_BINARY_OP_WITH_INT(-, decimal128)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal32, decimal32, decimal32)
_DECLARE_DECIMAL_BINARY_OP_WITH_INT(*, decimal32)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal64, decimal32, decimal64)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal64, decimal64, decimal32)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal64, decimal64, decimal64)
_DECLARE_DECIMAL_BINARY_OP_WITH_INT(*, decimal64)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal32, decimal128)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal64, decimal128)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal128, decimal32)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal128, decimal64)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal128, decimal128)
_DECLARE_DECIMAL_BINARY_OP_WITH_INT(*, decimal128)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal32, decimal32, decimal32)
_DECLARE_DECIMAL_BINARY_OP_WITH_INT(/, decimal32)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal64, decimal32, decimal64)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal64, decimal64, decimal32)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal64, decimal64, decimal64)
_DECLARE_DECIMAL_BINARY_OP_WITH_INT(/, decimal64)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal32, decimal128)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal64, decimal128)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal128, decimal32)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal128, decimal64)
_DECLARE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal128, decimal128)
_DECLARE_DECIMAL_BINARY_OP_WITH_INT(/, decimal128)
#undef _DECLARE_DECIMAL_BINARY_OP_WITH_DEC
#undef _DECLARE_DECIMAL_BINARY_OP_WITH_INT
// 3.2.9 Comparison operators.
#define _DECLARE_DECIMAL_COMPARISON(_Op, _T) \
bool operator _Op(_T lhs, decimal32 _rhs); \
bool operator _Op(_T lhs, decimal64 _rhs); \
bool operator _Op(_T lhs, decimal128 _rhs); \
bool operator _Op(_T lhs, int _rhs); \
bool operator _Op(_T lhs, unsigned int _rhs); \
bool operator _Op(_T lhs, long _rhs); \
bool operator _Op(_T lhs, unsigned long _rhs); \
bool operator _Op(_T lhs, long long _rhs); \
bool operator _Op(_T lhs, unsigned long long _rhs); \
bool operator _Op(int lhs, _T _rhs); \
bool operator _Op(unsigned int lhs, _T _rhs); \
bool operator _Op(long lhs, _T _rhs); \
bool operator _Op(unsigned long lhs, _T _rhs); \
bool operator _Op(long long lhs, _T _rhs); \
bool operator _Op(unsigned long long lhs, _T _rhs);
_DECLARE_DECIMAL_COMPARISON(==, decimal32)
_DECLARE_DECIMAL_COMPARISON(==, decimal64)
_DECLARE_DECIMAL_COMPARISON(==, decimal128)
_DECLARE_DECIMAL_COMPARISON(!=, decimal32)
_DECLARE_DECIMAL_COMPARISON(!=, decimal64)
_DECLARE_DECIMAL_COMPARISON(!=, decimal128)
_DECLARE_DECIMAL_COMPARISON(<, decimal32)
_DECLARE_DECIMAL_COMPARISON(<, decimal64)
_DECLARE_DECIMAL_COMPARISON(<, decimal128)
_DECLARE_DECIMAL_COMPARISON(>=, decimal32)
_DECLARE_DECIMAL_COMPARISON(>=, decimal64)
_DECLARE_DECIMAL_COMPARISON(>=, decimal128)
_DECLARE_DECIMAL_COMPARISON(>, decimal32)
_DECLARE_DECIMAL_COMPARISON(>, decimal64)
_DECLARE_DECIMAL_COMPARISON(>, decimal128)
_DECLARE_DECIMAL_COMPARISON(>=, decimal32)
_DECLARE_DECIMAL_COMPARISON(>=, decimal64)
_DECLARE_DECIMAL_COMPARISON(>=, decimal128)
#undef _DECLARE_DECIMAL_COMPARISON
/// 3.2.2 Class decimal32.
class decimal32
{
public:
typedef float __decfloat32 __attribute__((mode(SD)));
// 3.2.2.2 Construct/copy/destroy.
decimal32() : __val(0.e-101DF) {}
// 3.2.2.3 Conversion from floating-point type.
explicit decimal32(decimal64 __d64);
explicit decimal32(decimal128 __d128);
explicit decimal32(float __r) : __val(__r) {}
explicit decimal32(double __r) : __val(__r) {}
explicit decimal32(long double __r) : __val(__r) {}
// 3.2.2.4 Conversion from integral type.
decimal32(int __z) : __val(__z) {}
decimal32(unsigned int __z) : __val(__z) {}
decimal32(long __z) : __val(__z) {}
decimal32(unsigned long __z) : __val(__z) {}
decimal32(long long __z) : __val(__z) {}
decimal32(unsigned long long __z) : __val(__z) {}
/// Conforming extension: Conversion from scalar decimal type.
decimal32(__decfloat32 __z) : __val(__z) {}
// 3.2.2.5 Conversion to integral type. (DISABLED)
//operator long long() const { return (long long)__val; }
// 3.2.2.6 Increment and decrement operators.
decimal32& operator++()
{
__val += 1;
return *this;
}
decimal32 operator++(int)
{
decimal32 __tmp = *this;
__val += 1;
return __tmp;
}
decimal32& operator--()
{
__val -= 1;
return *this;
}
decimal32 operator--(int)
{
decimal32 __tmp = *this;
__val -= 1;
return __tmp;
}
// 3.2.2.7 Compound assignment.
#define _DECLARE_DECIMAL32_COMPOUND_ASSIGNMENT(_Op) \
decimal32& operator _Op(decimal32 __rhs); \
decimal32& operator _Op(decimal64 __rhs); \
decimal32& operator _Op(decimal128 __rhs); \
decimal32& operator _Op(int __rhs); \
decimal32& operator _Op(unsigned int __rhs); \
decimal32& operator _Op(long __rhs); \
decimal32& operator _Op(unsigned long __rhs); \
decimal32& operator _Op(long long __rhs); \
decimal32& operator _Op(unsigned long long __rhs);
_DECLARE_DECIMAL32_COMPOUND_ASSIGNMENT(+=)
_DECLARE_DECIMAL32_COMPOUND_ASSIGNMENT(-=)
_DECLARE_DECIMAL32_COMPOUND_ASSIGNMENT(*=)
_DECLARE_DECIMAL32_COMPOUND_ASSIGNMENT(/=)
#undef _DECLARE_DECIMAL32_COMPOUND_ASSIGNMENT
private:
__decfloat32 __val;
public:
__decfloat32 __getval(void) { return __val; }
void __setval(__decfloat32 __x) { __val = __x; }
};
/// 3.2.3 Class decimal64.
class decimal64
{
public:
typedef float __decfloat64 __attribute__((mode(DD)));
// 3.2.3.2 Construct/copy/destroy.
decimal64() : __val(0.e-398dd) {}
// 3.2.3.3 Conversion from floating-point type.
decimal64(decimal32 d32);
explicit decimal64(decimal128 d128);
explicit decimal64(float __r) : __val(__r) {}
explicit decimal64(double __r) : __val(__r) {}
explicit decimal64(long double __r) : __val(__r) {}
// 3.2.3.4 Conversion from integral type.
decimal64(int __z) : __val(__z) {}
decimal64(unsigned int __z) : __val(__z) {}
decimal64(long __z) : __val(__z) {}
decimal64(unsigned long __z) : __val(__z) {}
decimal64(long long __z) : __val(__z) {}
decimal64(unsigned long long __z) : __val(__z) {}
/// Conforming extension: Conversion from scalar decimal type.
decimal64(__decfloat64 __z) : __val(__z) {}
// 3.2.3.5 Conversion to integral type. (DISABLED)
//operator long long() const { return (long long)__val; }
// 3.2.3.6 Increment and decrement operators.
decimal64& operator++()
{
__val += 1;
return *this;
}
decimal64 operator++(int)
{
decimal64 __tmp = *this;
__val += 1;
return __tmp;
}
decimal64& operator--()
{
__val -= 1;
return *this;
}
decimal64 operator--(int)
{
decimal64 __tmp = *this;
__val -= 1;
return __tmp;
}
// 3.2.3.7 Compound assignment.
#define _DECLARE_DECIMAL64_COMPOUND_ASSIGNMENT(_Op) \
decimal64& operator _Op(decimal32 __rhs); \
decimal64& operator _Op(decimal64 __rhs); \
decimal64& operator _Op(decimal128 __rhs); \
decimal64& operator _Op(int __rhs); \
decimal64& operator _Op(unsigned int __rhs); \
decimal64& operator _Op(long __rhs); \
decimal64& operator _Op(unsigned long __rhs); \
decimal64& operator _Op(long long __rhs); \
decimal64& operator _Op(unsigned long long __rhs);
_DECLARE_DECIMAL64_COMPOUND_ASSIGNMENT(+=)
_DECLARE_DECIMAL64_COMPOUND_ASSIGNMENT(-=)
_DECLARE_DECIMAL64_COMPOUND_ASSIGNMENT(*=)
_DECLARE_DECIMAL64_COMPOUND_ASSIGNMENT(/=)
#undef _DECLARE_DECIMAL64_COMPOUND_ASSIGNMENT
private:
__decfloat64 __val;
public:
__decfloat64 __getval(void) { return __val; }
void __setval(__decfloat64 __x) { __val = __x; }
};
/// 3.2.4 Class decimal128.
class decimal128
{
public:
typedef float __decfloat128 __attribute__((mode(TD)));
// 3.2.4.2 Construct/copy/destroy.
decimal128() : __val(0.e-6176DL) {}
// 3.2.4.3 Conversion from floating-point type.
decimal128(decimal32 d32);
decimal128(decimal64 d64);
explicit decimal128(float __r) : __val(__r) {}
explicit decimal128(double __r) : __val(__r) {}
explicit decimal128(long double __r) : __val(__r) {}
// 3.2.4.4 Conversion from integral type.
decimal128(int __z) : __val(__z) {}
decimal128(unsigned int __z) : __val(__z) {}
decimal128(long __z) : __val(__z) {}
decimal128(unsigned long __z) : __val(__z) {}
decimal128(long long __z) : __val(__z) {}
decimal128(unsigned long long __z) : __val(__z) {}
/// Conforming extension: Conversion from scalar decimal type.
decimal128(__decfloat128 __z) : __val(__z) {}
// 3.2.4.5 Conversion to integral type. (DISABLED)
//operator long long() const { return (long long)__val; }
// 3.2.4.6 Increment and decrement operators.
decimal128& operator++()
{
__val += 1;
return *this;
}
decimal128 operator++(int)
{
decimal128 __tmp = *this;
__val += 1;
return __tmp;
}
decimal128& operator--()
{
__val -= 1;
return *this;
}
decimal128 operator--(int)
{
decimal128 __tmp = *this;
__val -= 1;
return __tmp;
}
// 3.2.4.7 Compound assignment.
#define _DECLARE_DECIMAL128_COMPOUND_ASSIGNMENT(_Op) \
decimal128& operator _Op(decimal32 __rhs); \
decimal128& operator _Op(decimal64 __rhs); \
decimal128& operator _Op(decimal128 __rhs); \
decimal128& operator _Op(int __rhs); \
decimal128& operator _Op(unsigned int __rhs); \
decimal128& operator _Op(long __rhs); \
decimal128& operator _Op(unsigned long __rhs); \
decimal128& operator _Op(long long __rhs); \
decimal128& operator _Op(unsigned long long __rhs);
_DECLARE_DECIMAL128_COMPOUND_ASSIGNMENT(+=)
_DECLARE_DECIMAL128_COMPOUND_ASSIGNMENT(-=)
_DECLARE_DECIMAL128_COMPOUND_ASSIGNMENT(*=)
_DECLARE_DECIMAL128_COMPOUND_ASSIGNMENT(/=)
#undef _DECLARE_DECIMAL128_COMPOUND_ASSIGNMENT
private:
__decfloat128 __val;
public:
__decfloat128 __getval(void) { return __val; }
void __setval(__decfloat128 __x) { __val = __x; }
};
#define _GLIBCXX_USE_DECIMAL_ 1
} // namespace decimal
// @} group decimal
} // namespace std
#include <decimal/decimal.h>
#endif /* _GLIBCXX_DECIMAL */

View File

@ -0,0 +1,519 @@
// decimal classes -*- C++ -*-
// Copyright (C) 2009 Free Software Foundation, Inc.
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/decimal.h
* This is an internal header file, included by other library headers.
* You should not attempt to use it directly.
*/
// ISO/IEC TR 24733
// Written by Janis Johnson <janis187@us.ibm.com>
#ifndef _GLIBCXX_DECIMAL_IMPL
#define _GLIBCXX_DECIMAL_IMPL 1
#pragma GCC system_header
namespace std
{
namespace decimal
{
// ISO/IEC TR 24733 3.2.[234].1 Construct/copy/destroy.
inline decimal32::decimal32(decimal64 r) : __val(r.__getval()) {}
inline decimal32::decimal32(decimal128 r) : __val(r.__getval()) {}
inline decimal64::decimal64(decimal32 r) : __val(r.__getval()) {}
inline decimal64::decimal64(decimal128 r) : __val(r.__getval()) {}
inline decimal128::decimal128(decimal32 r) : __val(r.__getval()) {}
inline decimal128::decimal128(decimal64 r) : __val(r.__getval()) {}
// ISO/IEC TR 24733 3.2.[234].6 Compound assignment.
#define _DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_DEC(_Op1, _Op2, _T1, _T2) \
inline _T1& _T1::operator _Op1(_T2 __rhs) \
{ \
__setval(__getval() _Op2 __rhs.__getval()); \
return *this; \
}
#define _DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_INT(_Op1, _Op2, _T1, _T2) \
inline _T1& _T1::operator _Op1(_T2 __rhs) \
{ \
__setval(__getval() _Op2 __rhs); \
return *this; \
}
#define _DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(_O1, _O2, _T1) \
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_DEC(_O1,_O2,_T1, decimal32) \
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_DEC(_O1,_O2,_T1, decimal64) \
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_DEC(_O1,_O2,_T1, decimal128) \
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_INT(_O1,_O2,_T1, int) \
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_INT(_O1,_O2,_T1, unsigned int) \
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_INT(_O1,_O2,_T1, long) \
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_INT(_O1,_O2,_T1, unsigned long) \
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_INT(_O1,_O2,_T1, long long) \
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_INT(_O1,_O2,_T1, unsigned long long)
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(+=, +, decimal32)
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(-=, -, decimal32)
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(*=, *, decimal32)
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(/=, /, decimal32)
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(+=, +, decimal64)
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(-=, -, decimal64)
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(*=, *, decimal64)
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(/=, /, decimal64)
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(+=, +, decimal128)
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(-=, -, decimal128)
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(*=, *, decimal128)
_DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS(/=, /, decimal128)
#undef _DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_DEC
#undef _DEFINE_DECIMAL_COMPOUND_ASSIGNMENT_INT
#undef _DEFINE_DECIMAL_COMPOUND_ASSIGNMENTS
// Extension: Conversion to integral type.
inline long long decimal32_to_long_long(decimal32 __d)
{
return (long long)__d.__getval();
}
inline long long decimal64_to_long_long(decimal64 __d)
{
return (long long)__d.__getval();
}
inline long long decimal128_to_long_long(decimal128 __d)
{
return (long long)__d.__getval();
}
inline long long decimal_to_long_long(decimal32 __d)
{
return (long long)__d.__getval();
}
inline long long decimal_to_long_long(decimal64 __d)
{
return (long long)__d.__getval();
}
inline long long decimal_to_long_long(decimal128 __d)
{
return (long long)__d.__getval();
}
// ISO/IEC TR 24733 3.2.5 Initialization from coefficient and exponent.
static decimal32 make_decimal32(long long __coeff, int __exponent)
{
decimal32 __decexp = 1, __multiplier;
if (__exponent < 0)
{
__multiplier = 1.E-1DF;
__exponent = -__exponent;
}
else
__multiplier = 1.E1DF;
for (int i = 0; i < __exponent; i++)
__decexp *= __multiplier;
return __coeff * __decexp;
}
static decimal32 make_decimal32(unsigned long long __coeff, int __exponent)
{
decimal32 __decexp = 1, __multiplier;
if (__exponent < 0)
{
__multiplier = 1.E-1DF;
__exponent = -__exponent;
}
else
__multiplier = 1.E1DF;
for (int i = 0; i < __exponent; i++)
__decexp *= __multiplier;
return __coeff * __decexp;
}
static decimal64 make_decimal64(long long __coeff, int __exponent)
{
decimal64 __decexp = 1, __multiplier;
if (__exponent < 0)
{
__multiplier = 1.E-1DD;
__exponent = -__exponent;
}
else
__multiplier = 1.E1DD;
for (int i = 0; i < __exponent; i++)
__decexp *= __multiplier;
return __coeff * __decexp;
}
static decimal64 make_decimal64(unsigned long long __coeff, int __exponent)
{
decimal64 __decexp = 1, __multiplier;
if (__exponent < 0)
{
__multiplier = 1.E-1DD;
__exponent = -__exponent;
}
else
__multiplier = 1.E1DD;
for (int i = 0; i < __exponent; i++)
__decexp *= __multiplier;
return __coeff * __decexp;
}
static decimal128 make_decimal128(long long __coeff, int __exponent)
{
decimal128 __decexp = 1, __multiplier;
if (__exponent < 0)
{
__multiplier = 1.E-1DL;
__exponent = -__exponent;
}
else
__multiplier = 1.E1DL;
for (int i = 0; i < __exponent; i++)
__decexp *= __multiplier;
return __coeff * __decexp;
}
static decimal128 make_decimal128(unsigned long long __coeff, int __exponent)
{
decimal128 __decexp = 1, __multiplier;
if (__exponent < 0)
{
__multiplier = 1.E-1DL;
__exponent = -__exponent;
}
else
__multiplier = 1.E1DL;
for (int i = 0; i < __exponent; i++)
__decexp *= __multiplier;
return __coeff * __decexp;
}
// ISO/IEC TR 24733 3.2.6 Conversion to generic floating-point type.
inline float decimal32_to_float(decimal32 __d)
{
return (float)__d.__getval();
}
inline float decimal64_to_float(decimal64 __d)
{
return (float)__d.__getval();
}
inline float decimal128_to_float(decimal128 __d)
{
return (float)__d.__getval();
}
inline float decimal_to_float(decimal32 __d)
{
return (float)__d.__getval();
}
inline float decimal_to_float(decimal64 __d)
{
return (float)__d.__getval();
}
inline float decimal_to_float(decimal128 __d)
{
return (float)__d.__getval();
}
inline double decimal32_to_double(decimal32 __d)
{
return (double)__d.__getval();
}
inline double decimal64_to_double(decimal64 __d)
{
return (double)__d.__getval();
}
inline double decimal128_to_double(decimal128 __d)
{
return (double)__d.__getval();
}
inline double decimal_to_double(decimal32 __d)
{
return (double)__d.__getval();
}
inline double decimal_to_double(decimal64 __d)
{
return (double)__d.__getval();
}
inline double decimal_to_double(decimal128 __d)
{
return (double)__d.__getval();
}
inline long double decimal32_to_long_double(decimal32 __d)
{
return (long double)__d.__getval();
}
inline long double decimal64_to_long_double(decimal64 __d)
{
return (long double)__d.__getval();
}
inline long double decimal128_to_long_double(decimal128 __d)
{
return (long double)__d.__getval();
}
inline long double decimal_to_long_double(decimal32 __d)
{
return (long double)__d.__getval();
}
inline long double decimal_to_long_double(decimal64 __d)
{
return (long double)__d.__getval();
}
inline long double decimal_to_long_double(decimal128 __d)
{
return (long double)__d.__getval();
}
// ISO/IEC TR 24733 3.2.7 Unary arithmetic operators.
#define _DEFINE_DECIMAL_UNARY_OP(_Op, _T) \
inline _T operator _Op(_T __rhs) \
{ \
_T __tmp; \
__tmp.__setval(0 _Op __rhs.__getval()); \
return __tmp; \
}
_DEFINE_DECIMAL_UNARY_OP(+, decimal32)
_DEFINE_DECIMAL_UNARY_OP(+, decimal64)
_DEFINE_DECIMAL_UNARY_OP(+, decimal128)
_DEFINE_DECIMAL_UNARY_OP(-, decimal32)
_DEFINE_DECIMAL_UNARY_OP(-, decimal64)
_DEFINE_DECIMAL_UNARY_OP(-, decimal128)
#undef _DEFINE_DECIMAL_UNARY_OP
// ISO/IEC TR 24733 3.2.8 Binary arithmetic operators.
#define _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(_Op, _T1, _T2, _T3) \
inline _T1 operator _Op(_T2 lhs, _T3 __rhs) \
{ \
_T1 retval; \
retval.__setval(lhs.__getval() _Op __rhs.__getval()); \
return retval; \
}
#define _DEFINE_DECIMAL_BINARY_OP_BOTH(_Op, _T1, _T2, _T3) \
inline _T1 operator _Op(_T2 lhs, _T3 __rhs) \
{ \
_T1 retval; \
retval.__setval(lhs.__getval() _Op __rhs.__getval()); \
return retval; \
}
#define _DEFINE_DECIMAL_BINARY_OP_LHS(_Op, _T1, _T2) \
inline _T1 operator _Op(_T1 lhs, _T2 __rhs) \
{ \
_T1 retval; \
retval.__setval(lhs.__getval() _Op __rhs); \
return retval; \
}
#define _DEFINE_DECIMAL_BINARY_OP_RHS(_Op, _T1, _T2) \
inline _T1 operator _Op(_T2 lhs, _T1 __rhs) \
{ \
_T1 retval; \
retval.__setval(lhs _Op __rhs.__getval()); \
return retval; \
}
#define _DEFINE_DECIMAL_BINARY_OP_WITH_INT(_Op,_Tp) \
_DEFINE_DECIMAL_BINARY_OP_LHS(_Op,_Tp, int); \
_DEFINE_DECIMAL_BINARY_OP_LHS(_Op,_Tp, unsigned int); \
_DEFINE_DECIMAL_BINARY_OP_LHS(_Op,_Tp, long); \
_DEFINE_DECIMAL_BINARY_OP_LHS(_Op,_Tp, unsigned long); \
_DEFINE_DECIMAL_BINARY_OP_LHS(_Op,_Tp, long long); \
_DEFINE_DECIMAL_BINARY_OP_LHS(_Op,_Tp, unsigned long long); \
_DEFINE_DECIMAL_BINARY_OP_RHS(_Op,_Tp, int); \
_DEFINE_DECIMAL_BINARY_OP_RHS(_Op,_Tp, unsigned int); \
_DEFINE_DECIMAL_BINARY_OP_RHS(_Op,_Tp, long); \
_DEFINE_DECIMAL_BINARY_OP_RHS(_Op,_Tp, unsigned long); \
_DEFINE_DECIMAL_BINARY_OP_RHS(_Op,_Tp, long long); \
_DEFINE_DECIMAL_BINARY_OP_RHS(_Op,_Tp, unsigned long long); \
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal32, decimal32, decimal32)
_DEFINE_DECIMAL_BINARY_OP_WITH_INT(+, decimal32)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal64, decimal32, decimal64)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal64, decimal64, decimal32)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal64, decimal64, decimal64)
_DEFINE_DECIMAL_BINARY_OP_WITH_INT(+, decimal64)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal32, decimal128)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal64, decimal128)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal128, decimal32)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal128, decimal64)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal128, decimal128, decimal128)
_DEFINE_DECIMAL_BINARY_OP_WITH_INT(+, decimal128)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal32, decimal32, decimal32)
_DEFINE_DECIMAL_BINARY_OP_WITH_INT(-, decimal32)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal64, decimal32, decimal64)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal64, decimal64, decimal32)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal64, decimal64, decimal64)
_DEFINE_DECIMAL_BINARY_OP_WITH_INT(-, decimal64)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal32, decimal128)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal64, decimal128)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal128, decimal32)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal128, decimal64)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(-, decimal128, decimal128, decimal128)
_DEFINE_DECIMAL_BINARY_OP_WITH_INT(-, decimal128)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal32, decimal32, decimal32)
_DEFINE_DECIMAL_BINARY_OP_WITH_INT(*, decimal32)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal64, decimal32, decimal64)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal64, decimal64, decimal32)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal64, decimal64, decimal64)
_DEFINE_DECIMAL_BINARY_OP_WITH_INT(*, decimal64)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal32, decimal128)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal64, decimal128)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal128, decimal32)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal128, decimal64)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(*, decimal128, decimal128, decimal128)
_DEFINE_DECIMAL_BINARY_OP_WITH_INT(*, decimal128)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal32, decimal32, decimal32)
_DEFINE_DECIMAL_BINARY_OP_WITH_INT(/, decimal32)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal64, decimal32, decimal64)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal64, decimal64, decimal32)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal64, decimal64, decimal64)
_DEFINE_DECIMAL_BINARY_OP_WITH_INT(/, decimal64)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal32, decimal128)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal64, decimal128)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal128, decimal32)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal128, decimal64)
_DEFINE_DECIMAL_BINARY_OP_WITH_DEC(/, decimal128, decimal128, decimal128)
_DEFINE_DECIMAL_BINARY_OP_WITH_INT(/, decimal128)
#undef _DEFINE_DECIMAL_BINARY_OP_WITH_DEC
#undef _DEFINE_DECIMAL_BINARY_OP_BOTH
#undef _DEFINE_DECIMAL_BINARY_OP_LHS
#undef _DEFINE_DECIMAL_BINARY_OP_RHS
#undef _DEFINE_DECIMAL_BINARY_OP_WITH_INT
// ISO/IEC TR 24733 3.2.9 Comparison operators.
#define _DEFINE_DECIMAL_COMPARISON_BOTH(_Op, _T1, _T2) \
inline bool operator _Op(_T1 lhs, _T2 __rhs) \
{ \
return lhs.__getval() _Op __rhs.__getval(); \
}
#define _DEFINE_DECIMAL_COMPARISON_LHS(_Op, _T1, _T2) \
inline bool operator _Op(_T1 lhs, _T2 __rhs) \
{ \
return lhs.__getval() _Op __rhs; \
}
#define _DEFINE_DECIMAL_COMPARISON_RHS(_Op, _T1, _T2) \
inline bool operator _Op(_T1 lhs, _T2 __rhs) \
{ \
return lhs _Op __rhs.__getval(); \
}
#define _DEFINE_DECIMAL_COMPARISONS(_Op, _Tp) \
_DEFINE_DECIMAL_COMPARISON_BOTH(_Op, _Tp, decimal32) \
_DEFINE_DECIMAL_COMPARISON_BOTH(_Op, _Tp, decimal64) \
_DEFINE_DECIMAL_COMPARISON_BOTH(_Op, _Tp, decimal128) \
_DEFINE_DECIMAL_COMPARISON_LHS(_Op, _Tp, int) \
_DEFINE_DECIMAL_COMPARISON_LHS(_Op, _Tp, unsigned int) \
_DEFINE_DECIMAL_COMPARISON_LHS(_Op, _Tp, long) \
_DEFINE_DECIMAL_COMPARISON_LHS(_Op, _Tp, unsigned long) \
_DEFINE_DECIMAL_COMPARISON_LHS(_Op, _Tp, long long) \
_DEFINE_DECIMAL_COMPARISON_LHS(_Op, _Tp, unsigned long long) \
_DEFINE_DECIMAL_COMPARISON_RHS(_Op, int, _Tp) \
_DEFINE_DECIMAL_COMPARISON_RHS(_Op, unsigned int, _Tp) \
_DEFINE_DECIMAL_COMPARISON_RHS(_Op, long, _Tp) \
_DEFINE_DECIMAL_COMPARISON_RHS(_Op, unsigned long, _Tp) \
_DEFINE_DECIMAL_COMPARISON_RHS(_Op, long long, _Tp) \
_DEFINE_DECIMAL_COMPARISON_RHS(_Op, unsigned long long, _Tp)
_DEFINE_DECIMAL_COMPARISONS(==, decimal32)
_DEFINE_DECIMAL_COMPARISONS(==, decimal64)
_DEFINE_DECIMAL_COMPARISONS(==, decimal128)
_DEFINE_DECIMAL_COMPARISONS(!=, decimal32)
_DEFINE_DECIMAL_COMPARISONS(!=, decimal64)
_DEFINE_DECIMAL_COMPARISONS(!=, decimal128)
_DEFINE_DECIMAL_COMPARISONS(<, decimal32)
_DEFINE_DECIMAL_COMPARISONS(<, decimal64)
_DEFINE_DECIMAL_COMPARISONS(<, decimal128)
_DEFINE_DECIMAL_COMPARISONS(<=, decimal32)
_DEFINE_DECIMAL_COMPARISONS(<=, decimal64)
_DEFINE_DECIMAL_COMPARISONS(<=, decimal128)
_DEFINE_DECIMAL_COMPARISONS(>, decimal32)
_DEFINE_DECIMAL_COMPARISONS(>, decimal64)
_DEFINE_DECIMAL_COMPARISONS(>, decimal128)
_DEFINE_DECIMAL_COMPARISONS(>=, decimal32)
_DEFINE_DECIMAL_COMPARISONS(>=, decimal64)
_DEFINE_DECIMAL_COMPARISONS(>=, decimal128)
#undef _DEFINE_DECIMAL_COMPARISON_BOTH
#undef _DEFINE_DECIMAL_COMPARISON_LHS
#undef _DEFINE_DECIMAL_COMPARISON_RHS
#undef _DEFINE_DECIMAL_COMPARISONS
} // namespace decimal
} // namespace std
#endif /* _GLIBCXX_DECIMAL_IMPL */

View File

@ -10,12 +10,12 @@
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
//
//
// GCC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
@ -38,7 +38,7 @@
extern "C++" {
namespace std
namespace std
{
/**
* @defgroup exceptions Exceptions
@ -56,7 +56,7 @@ namespace std
* your own %exception classes, or use a different hierarchy, or to
* throw non-class data (e.g., fundamental types).
*/
class exception
class exception
{
public:
exception() throw() { }
@ -69,7 +69,7 @@ namespace std
/** If an %exception is thrown which is not listed in a function's
* %exception specification, one of these may be thrown. */
class bad_exception : public exception
class bad_exception : public exception
{
public:
bad_exception() throw() { }
@ -119,10 +119,10 @@ namespace std
_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
/**
/**
* @brief A replacement for the standard terminate_handler which
* prints more information about the terminating exception (if any)
* on stderr.
* on stderr.
*
* @ingroup exceptions
*
@ -138,7 +138,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
void __verbose_terminate_handler();
_GLIBCXX_END_NAMESPACE
} // extern "C++"
#pragma GCC visibility pop

View File

@ -32,7 +32,7 @@ cd $srcdir
# This is the ugly version of "everything but the current directory". It's
# what has to happen when find(1) doesn't support -mindepth, or -xtype.
dlist=`echo [0-9][0-9]*`
dlist="$dlist abi backward ext performance tr1"
dlist="$dlist abi backward ext performance tr1 decimal"
find $dlist "(" -type f -o -type l ")" -name "*.cc" -print > $tmp.01
find $dlist "(" -type f -o -type l ")" -name "*.c" -print > $tmp.02
cat $tmp.01 $tmp.02 | sort > $tmp.1

View File

@ -299,7 +299,7 @@ libgomp_flags = -B${glibcxx_builddir}/../libgomp \
atomic_flags = $(ATOMIC_FLAGS)
parallel_flags = "unix/-D_GLIBCXX_PARALLEL/-fopenmp"
# Runs the testsuite in profile
# Runs the testsuite in profile mode.
profile_flags = "unix/-D_GLIBCXX_PROFILE"
# By adding these files here, automake will remove them for 'make clean'
@ -652,7 +652,7 @@ check-profile: site.exp
fi; \
srcdir=`$(am__cd) $(srcdir) && pwd`; export srcdir; \
EXPECT=$(EXPECT); export EXPECT; \
$(MAKE) CXXFLAGS="$(atomic_flags)" RUNTESTFLAGS="$(RUNTESTFLAGS) conformance.exp --outdir $${outputdir} --objdir $${outputdir} --target_board=$(profile_flags)" check-DEJAGNU; )
$(MAKE) CXXFLAGS="$(atomic_flags) " RUNTESTFLAGS="$(RUNTESTFLAGS) conformance.exp --outdir $${outputdir} --objdir $${outputdir} --target_board=$(profile_flags)" check-DEJAGNU; )
.PHONY: baseline_symbols new-abi-baseline \
check-abi check-compile check-performance check-parallel check-profile

View File

@ -0,0 +1,372 @@
// Copyright (C) 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-require-effective-target-dfp }
// ISO/IEC TR 24733 3.2.8 Binary arithmetic operators.
#include <decimal/decimal>
#include <testsuite_hooks.h>
using namespace std::decimal;
decimal32 d32 (5);
decimal64 d64 (-10);
decimal128 d128 (25);
int si = -20;
unsigned int ui = 50;
long sl = -10;
unsigned long ul = 20;
long long sll = -25;
unsigned long long ull = 50;
void
binary_add_32 (void)
{
decimal32 a (1000), b;
b = si + a; VERIFY (b == 980);
b = ui + a; VERIFY (b == 1050);
b = sl + a; VERIFY (b == 990);
b = ul + a; VERIFY (b == 1020);
b = sll + a; VERIFY (b == 975);
b = ull + a; VERIFY (b == 1050);
b = d32 + a; VERIFY (b == 1005);
b = (decimal32)(d64 + a); VERIFY (b == 990);
b = (decimal32)(d128 + a); VERIFY (b == 1025);
b = a + si; VERIFY (b == 980);
b = a + ui; VERIFY (b == 1050);
b = a + sl; VERIFY (b == 990);
b = a + ul; VERIFY (b == 1020);
b = a + sll; VERIFY (b == 975);
b = a + ull; VERIFY (b == 1050);
b = a + d32; VERIFY (b == 1005);
b = (decimal32)(a + d64); VERIFY (b == 990);
b = (decimal32)(a + d128); VERIFY (b == 1025);
}
void
binary_subtract_32 (void)
{
decimal32 a (1000), b;
b = a - si; VERIFY (b == 1020);
b = a - ui; VERIFY (b == 950);
b = a - sl; VERIFY (b == 1010);
b = a - ul; VERIFY (b == 980);
b = a - sll; VERIFY (b == 1025);
b = a - ull; VERIFY (b == 950);
b = a - d32; VERIFY (b == 995);
b = (decimal32)(a - d64); VERIFY (b == 1010);
b = (decimal32)(a - d128); VERIFY (b == 975);
a = -1000;
b = si - a; VERIFY (b == 980);
b = ui - a; VERIFY (b == 1050);
b = sl - a; VERIFY (b == 990);
b = ul - a; VERIFY (b == 1020);
b = sll - a; VERIFY (b == 975);
b = ull - a; VERIFY (b == 1050);
b = d32 - a; VERIFY (b == 1005);
b = (decimal32)(d64 - a); VERIFY (b == 990);
b = (decimal32)(d128 - a); VERIFY (b == 1025);
}
void
binary_multiply_32 (void)
{
decimal32 a (1000), b;
b = a * si; VERIFY (b == -20000);
b = a * ui; VERIFY (b == 50000);
b = a * sl; VERIFY (b == -10000);
b = a * ul; VERIFY (b == 20000);
b = a * sll; VERIFY (b == -25000);
b = a * ull; VERIFY (b == 50000);
b = a * d32; VERIFY (b == 5000);
b = (decimal32)(a * d64); VERIFY (b == -10000);
b = (decimal32)(a * d128); VERIFY (b == 25000);
b = si * a; VERIFY (b == -20000);
b = ui * a; VERIFY (b == 50000);
b = sl * a; VERIFY (b == -10000);
b = ul * a; VERIFY (b == 20000);
b = sll * a; VERIFY (b == -25000);
b = ull * a; VERIFY (b == 50000);
b = d32 * a; VERIFY (b == 5000);
b = (decimal32)(d64 * a); VERIFY (b == -10000);
b = (decimal32)(d128 * a); VERIFY (b == 25000);
}
void
binary_divide_32 (void)
{
decimal32 a (1000), b;
b = a / si; VERIFY (b == -50);
b = a / ui; VERIFY (b == 20);
b = a / sl; VERIFY (b == -100);
b = a / ul; VERIFY (b == 50);
b = a / sll; VERIFY (b == -40);
b = a / ull; VERIFY (b == 20);
b = a / d32; VERIFY (b == 200);
b = (decimal32)(a / d64); VERIFY (b == -100);
b = (decimal32)(a / d128); VERIFY (b == 40);
a = 5;
b = si / a; VERIFY (b == -4);
b = ui / a; VERIFY (b == 10);
b = sl / a; VERIFY (b == -2);
b = ul / a; VERIFY (b == 4);
b = sll / a; VERIFY (b == -5);
b = ull / a; VERIFY (b == 10);
b = d32 / a; VERIFY (b == 1);
b = (decimal32)(d64 / a); VERIFY (b == -2);
b = (decimal32)(d128 / a); VERIFY (b == 5);
}
void
binary_add_64 (void)
{
decimal64 a (1000), b;
b = a + si; VERIFY (b == 980);
b = a + ui; VERIFY (b == 1050);
b = a + sl; VERIFY (b == 990);
b = a + ul; VERIFY (b == 1020);
b = a + sll; VERIFY (b == 975);
b = a + ull; VERIFY (b == 1050);
b = a + d32; VERIFY (b == 1005);
b = a + d64; VERIFY (b == 990);
b = (decimal64)(a + d128); VERIFY (b == 1025);
b = a + si; VERIFY (b == 980);
b = a + ui; VERIFY (b == 1050);
b = a + sl; VERIFY (b == 990);
b = a + ul; VERIFY (b == 1020);
b = a + sll; VERIFY (b == 975);
b = a + ull; VERIFY (b == 1050);
b = a + d32; VERIFY (b == 1005);
b = a + d64; VERIFY (b == 990);
b = (decimal64)(a + d128); VERIFY (b == 1025);
}
void
binary_subtract_64 (void)
{
decimal64 a (1000), b;
b = a - si; VERIFY (b == 1020);
b = a - ui; VERIFY (b == 950);
b = a - sl; VERIFY (b == 1010);
b = a - ul; VERIFY (b == 980);
b = a - sll; VERIFY (b == 1025);
b = a - ull; VERIFY (b == 950);
b = a - d32; VERIFY (b == 995);
b = a - d64; VERIFY (b == 1010);
b = (decimal64)(a - d128); VERIFY (b == 975);
a = -1000;
b = si - a; VERIFY (b == 980);
b = ui - a; VERIFY (b == 1050);
b = sl - a; VERIFY (b == 990);
b = ul - a; VERIFY (b == 1020);
b = sll - a; VERIFY (b == 975);
b = ull - a; VERIFY (b == 1050);
b = d32 - a; VERIFY (b == 1005);
b = d64 - a; VERIFY (b == 990);
b = (decimal64)(d128 - a); VERIFY (b == 1025);
}
void
binary_multiply_64 (void)
{
decimal64 a (1000), b;
b = a * si; VERIFY (b == -20000);
b = a * ui; VERIFY (b == 50000);
b = a * sl; VERIFY (b == -10000);
b = a * ul; VERIFY (b == 20000);
b = a * sll; VERIFY (b == -25000);
b = a * ull; VERIFY (b == 50000);
b = a * d32; VERIFY (b == 5000);
b = a * d64; VERIFY (b == -10000);
b = (decimal64)(a * d128); VERIFY (b == 25000);
b = si * a; VERIFY (b == -20000);
b = ui * a; VERIFY (b == 50000);
b = sl * a; VERIFY (b == -10000);
b = ul * a; VERIFY (b == 20000);
b = sll * a; VERIFY (b == -25000);
b = ull * a; VERIFY (b == 50000);
b = d32 * a; VERIFY (b == 5000);
b = d64 * a; VERIFY (b == -10000);
b = (decimal64)(d128 * a); VERIFY (b == 25000);
}
void
binary_divide_64 (void)
{
decimal64 a (1000), b;
b = a / si; VERIFY (b == -50);
b = a / ui; VERIFY (b == 20);
b = a / sl; VERIFY (b == -100);
b = a / ul; VERIFY (b == 50);
b = a / sll; VERIFY (b == -40);
b = a / ull; VERIFY (b == 20);
b = a / d32; VERIFY (b == 200);
b = a / d64; VERIFY (b == -100);
b = (decimal64)(a / d128); VERIFY (b == 40);
a = 5;
b = si / a; VERIFY (b == -4);
b = ui / a; VERIFY (b == 10);
b = sl / a; VERIFY (b == -2);
b = ul / a; VERIFY (b == 4);
b = sll / a; VERIFY (b == -5);
b = ull / a; VERIFY (b == 10);
b = d32 / a; VERIFY (b == 1);
b = d64 / a; VERIFY (b == -2);
b = (decimal64)(d128 / a); VERIFY (b == 5);
}
void
binary_add_128 (void)
{
decimal128 a (1000), b;
b = a + si; VERIFY (b == 980);
b = a + ui; VERIFY (b == 1050);
b = a + sl; VERIFY (b == 990);
b = a + ul; VERIFY (b == 1020);
b = a + sll; VERIFY (b == 975);
b = a + ull; VERIFY (b == 1050);
b = a + d32; VERIFY (b == 1005);
b = a + d64; VERIFY (b == 990);
b = a + d128; VERIFY (b == 1025);
b = a + si; VERIFY (b == 980);
b = a + ui; VERIFY (b == 1050);
b = a + sl; VERIFY (b == 990);
b = a + ul; VERIFY (b == 1020);
b = a + sll; VERIFY (b == 975);
b = a + ull; VERIFY (b == 1050);
b = a + d32; VERIFY (b == 1005);
b = a + d64; VERIFY (b == 990);
b = a + d128; VERIFY (b == 1025);
}
void
binary_subtract_128 (void)
{
decimal128 a (1000), b;
b = a - si; VERIFY (b == 1020);
b = a - ui; VERIFY (b == 950);
b = a - sl; VERIFY (b == 1010);
b = a - ul; VERIFY (b == 980);
b = a - sll; VERIFY (b == 1025);
b = a - ull; VERIFY (b == 950);
b = a - d32; VERIFY (b == 995);
b = a - d64; VERIFY (b == 1010);
b = a - d128; VERIFY (b == 975);
a = -1000;
b = si - a; VERIFY (b == 980);
b = ui - a; VERIFY (b == 1050);
b = sl - a; VERIFY (b == 990);
b = ul - a; VERIFY (b == 1020);
b = sll - a; VERIFY (b == 975);
b = ull - a; VERIFY (b == 1050);
b = d32 - a; VERIFY (b == 1005);
b = d64 - a; VERIFY (b == 990);
b = d128 - a; VERIFY (b == 1025);
}
void
binary_multiply_128 (void)
{
decimal128 a (1000), b;
b = a * si; VERIFY (b == -20000);
b = a * ui; VERIFY (b == 50000);
b = a * sl; VERIFY (b == -10000);
b = a * ul; VERIFY (b == 20000);
b = a * sll; VERIFY (b == -25000);
b = a * ull; VERIFY (b == 50000);
b = a * d32; VERIFY (b == 5000);
b = a * d64; VERIFY (b == -10000);
b = a * d128; VERIFY (b == 25000);
b = si * a; VERIFY (b == -20000);
b = ui * a; VERIFY (b == 50000);
b = sl * a; VERIFY (b == -10000);
b = ul * a; VERIFY (b == 20000);
b = sll * a; VERIFY (b == -25000);
b = ull * a; VERIFY (b == 50000);
b = d32 * a; VERIFY (b == 5000);
b = d64 * a; VERIFY (b == -10000);
b = d128 * a; VERIFY (b == 25000);
}
void
binary_divide_128 (void)
{
decimal128 a (1000), b;
b = a / si; VERIFY (b == -50);
b = a / ui; VERIFY (b == 20);
b = a / sl; VERIFY (b == -100);
b = a / ul; VERIFY (b == 50);
b = a / sll; VERIFY (b == -40);
b = a / ull; VERIFY (b == 20);
b = a / d32; VERIFY (b == 200);
b = a / d64; VERIFY (b == -100);
b = a / d128; VERIFY (b == 40);
a = 5;
b = si / a; VERIFY (b == -4);
b = ui / a; VERIFY (b == 10);
b = sl / a; VERIFY (b == -2);
b = ul / a; VERIFY (b == 4);
b = sll / a; VERIFY (b == -5);
b = ull / a; VERIFY (b == 10);
b = d32 / a; VERIFY (b == 1);
b = d64 / a; VERIFY (b == -2);
b = d128 / a; VERIFY (b == 5);
}
int
main ()
{
binary_add_32 ();
binary_subtract_32 ();
binary_multiply_32 ();
binary_divide_32 ();
binary_add_64 ();
binary_subtract_64 ();
binary_multiply_64 ();
binary_divide_64 ();
binary_add_128 ();
binary_subtract_128 ();
binary_multiply_128 ();
binary_divide_128 ();
}

View File

@ -0,0 +1,62 @@
// Copyright (C) 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-do compile }
// { dg-require-effective-target-dfp }
// ISO/IEC TR 24733 doesn't say explicitly that the conversion from a
// decimal floating-point type to a generic float type is prohibited but
// it implies that in section 4.3 when it says "In C, objects of decimal
// floating-oint type can be converted to generic floating-point type by
// means of an explicit cast. In C++ this is not possible." Check that
// attempt to do a cast are flagged as errors.
#include <decimal/decimal>
#include <testsuite_hooks.h>
using namespace std::decimal;
float f;
double d;
long double ld;
decimal32 d32;
decimal64 d64;
decimal128 d128;
void
foo (void)
{
f = d32; // { dg-error "error" }
f = d64; // { dg-error "error" }
f = d128; // { dg-error "error" }
d = d32; // { dg-error "error" }
d = d64; // { dg-error "error" }
d = d128; // { dg-error "error" }
ld = d32; // { dg-error "error" }
ld = d64; // { dg-error "error" }
ld = d128; // { dg-error "error" }
f = (float)d32; // { dg-error "error" }
f = (float)d64; // { dg-error "error" }
f = (float)d128; // { dg-error "error" }
d = (double)d32; // { dg-error "error" }
d = (double)d64; // { dg-error "error" }
d = (double)d128; // { dg-error "error" }
ld = (long double)d32; // { dg-error "error" }
ld = (long double)d64; // { dg-error "error" }
ld = (long double)d128; // { dg-error "error" }
}

View File

@ -0,0 +1,546 @@
// Copyright (C) 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-require-effective-target-dfp }
// ISO/IEC TR 24733 3.2.9 Comparison operators.
#include <decimal/decimal>
#include <testsuite_hooks.h>
using namespace std::decimal;
decimal32 d32 (5);
decimal64 d64 (-10);
decimal128 d128 (25);
int si = -20;
unsigned int ui = 50;
long sl = -10;
unsigned long ul = 20;
long long sll = -25;
unsigned long long ull = 50;
void
compare_eq_32 (void)
{
decimal32 a;
a = si; VERIFY (a == si); VERIFY (si == a);
a = ui; VERIFY (a == ui); VERIFY (ui == a);
a = sl; VERIFY (a == sl); VERIFY (sl == a);
a = ul; VERIFY (a == ul); VERIFY (ul == a);
a = sll; VERIFY (a == sll); VERIFY (sll == a);
a = ull; VERIFY (a == ull); VERIFY (ull == a);
a = d32; VERIFY (a == d32); VERIFY (d32 == a);
a = (decimal32)d64; VERIFY (a == d64); VERIFY (d64 == a);
a = (decimal32)d128; VERIFY (a == d128); VERIFY (d128 == a);
}
void
compare_ne_32 (void)
{
decimal32 a = 100;
VERIFY (a != si); VERIFY (si != a);
VERIFY (a != ui); VERIFY (ui != a);
VERIFY (a != sl); VERIFY (sl != a);
VERIFY (a != ul); VERIFY (ul != a);
VERIFY (a != sll); VERIFY (sll != a);
VERIFY (a != ull); VERIFY (ull != a);
VERIFY (a != d32); VERIFY (d32 != a);
VERIFY (a != d64); VERIFY (d64 != a);
VERIFY (a != d128); VERIFY (d128 != a);
}
void
compare_lt_32 (void)
{
decimal32 a = -100;
VERIFY (a < si);
VERIFY (a < ui);
VERIFY (a < sl);
VERIFY (a < ul);
VERIFY (a < sll);
VERIFY (a < ull);
VERIFY (a < d32);
VERIFY (a < d64);
VERIFY (a < d128);
a = 100;
VERIFY (si < a);
VERIFY (ui < a);
VERIFY (sl < a);
VERIFY (ul < a);
VERIFY (sll < a);
VERIFY (ull < a);
VERIFY (d32 < a);
VERIFY (d64 < a);
VERIFY (d128 < a);
}
void
compare_le_32 (void)
{
decimal32 a;
a = si; VERIFY (a <= si); VERIFY (si <= a);
a = ui; VERIFY (a <= ui); VERIFY (ui <= a);
a = sl; VERIFY (a <= sl); VERIFY (sl <= a);
a = ul; VERIFY (a <= ul); VERIFY (ul <= a);
a = sll; VERIFY (a <= sll); VERIFY (sll <= a);
a = ull; VERIFY (a <= ull); VERIFY (ull <= a);
a = d32; VERIFY (a <= d32); VERIFY (d32 <= a);
a = (decimal32)d64; VERIFY (a <= d64); VERIFY (d64 <= a);
a = (decimal32)d128; VERIFY (a <= d128); VERIFY (d128 <= a);
a = -100;
VERIFY (a <= si);
VERIFY (a <= ui);
VERIFY (a <= sl);
VERIFY (a <= ul);
VERIFY (a <= sll);
VERIFY (a <= ull);
VERIFY (a <= d32);
VERIFY (a <= d64);
VERIFY (a <= d128);
a = 100;
VERIFY (si <= a);
VERIFY (ui <= a);
VERIFY (sl <= a);
VERIFY (ul <= a);
VERIFY (sll <= a);
VERIFY (ull <= a);
VERIFY (d32 <= a);
VERIFY (d64 <= a);
VERIFY (d128 <= a);
}
void
compare_gt_32 (void)
{
decimal32 a = 100;
VERIFY (a > si);
VERIFY (a > ui);
VERIFY (a > sl);
VERIFY (a > ul);
VERIFY (a > sll);
VERIFY (a > ull);
VERIFY (a > d32);
VERIFY (a > d64);
VERIFY (a > d128);
a = -100;
VERIFY (si > a);
VERIFY (ui > a);
VERIFY (sl > a);
VERIFY (ul > a);
VERIFY (sll > a);
VERIFY (ull > a);
VERIFY (d32 > a);
VERIFY (d64 > a);
VERIFY (d128 > a);
}
void
compare_ge_32 (void)
{
decimal32 a;
a = si; VERIFY (a >= si); VERIFY (si <= a);
a = ui; VERIFY (a >= ui); VERIFY (ui <= a);
a = sl; VERIFY (a >= sl); VERIFY (sl <= a);
a = ul; VERIFY (a >= ul); VERIFY (ul <= a);
a = sll; VERIFY (a >= sll); VERIFY (sll <= a);
a = ull; VERIFY (a >= ull); VERIFY (ull <= a);
a = d32; VERIFY (a >= d32); VERIFY (d32 <= a);
a = (decimal32)d64; VERIFY (a >= d64); VERIFY (d64 <= a);
a = (decimal32)d128; VERIFY (a >= d128); VERIFY (d128 <= a);
a = 100;
VERIFY (a >= si);
VERIFY (a >= ui);
VERIFY (a >= sl);
VERIFY (a >= ul);
VERIFY (a >= sll);
VERIFY (a >= ull);
VERIFY (a >= d32);
VERIFY (a >= d64);
VERIFY (a >= d128);
a = -100;
VERIFY (si >= a);
VERIFY (ui >= a);
VERIFY (sl >= a);
VERIFY (ul >= a);
VERIFY (sll >= a);
VERIFY (ull >= a);
VERIFY (d32 >= a);
VERIFY (d64 >= a);
VERIFY (d128 >= a);
}
void
compare_eq_64 (void)
{
decimal64 a;
a = si; VERIFY (a == si); VERIFY (si == a);
a = ui; VERIFY (a == ui); VERIFY (ui == a);
a = sl; VERIFY (a == sl); VERIFY (sl == a);
a = ul; VERIFY (a == ul); VERIFY (ul == a);
a = sll; VERIFY (a == sll); VERIFY (sll == a);
a = ull; VERIFY (a == ull); VERIFY (ull == a);
a = d32; VERIFY (a == d32); VERIFY (d32 == a);
a = d64; VERIFY (a == d64); VERIFY (d64 == a);
a = (decimal64)d128; VERIFY (a == d128); VERIFY (d128 == a);
}
void
compare_ne_64 (void)
{
decimal64 a = 100;
VERIFY (a != si); VERIFY (si != a);
VERIFY (a != ui); VERIFY (ui != a);
VERIFY (a != sl); VERIFY (sl != a);
VERIFY (a != ul); VERIFY (ul != a);
VERIFY (a != sll); VERIFY (sll != a);
VERIFY (a != ull); VERIFY (ull != a);
VERIFY (a != d32); VERIFY (d32 != a);
VERIFY (a != d64); VERIFY (d64 != a);
VERIFY (a != d128); VERIFY (d128 != a);
}
void
compare_lt_64 (void)
{
decimal64 a = -100;
VERIFY (a < si);
VERIFY (a < ui);
VERIFY (a < sl);
VERIFY (a < ul);
VERIFY (a < sll);
VERIFY (a < ull);
VERIFY (a < d32);
VERIFY (a < d64);
VERIFY (a < d128);
a = 100;
VERIFY (si < a);
VERIFY (ui < a);
VERIFY (sl < a);
VERIFY (ul < a);
VERIFY (sll < a);
VERIFY (ull < a);
VERIFY (d32 < a);
VERIFY (d64 < a);
VERIFY (d128 < a);
}
void
compare_le_64 (void)
{
decimal64 a;
a = si; VERIFY (a <= si); VERIFY (si <= a);
a = ui; VERIFY (a <= ui); VERIFY (ui <= a);
a = sl; VERIFY (a <= sl); VERIFY (sl <= a);
a = ul; VERIFY (a <= ul); VERIFY (ul <= a);
a = sll; VERIFY (a <= sll); VERIFY (sll <= a);
a = ull; VERIFY (a <= ull); VERIFY (ull <= a);
a = d32; VERIFY (a <= d32); VERIFY (d32 <= a);
a = (decimal32)d64; VERIFY (a <= d64); VERIFY (d64 <= a);
a = (decimal32)d128; VERIFY (a <= d128); VERIFY (d128 <= a);
a = -100;
VERIFY (a <= si);
VERIFY (a <= ui);
VERIFY (a <= sl);
VERIFY (a <= ul);
VERIFY (a <= sll);
VERIFY (a <= ull);
VERIFY (a <= d32);
VERIFY (a <= d64);
VERIFY (a <= d128);
a = 100;
VERIFY (si <= a);
VERIFY (ui <= a);
VERIFY (sl <= a);
VERIFY (ul <= a);
VERIFY (sll <= a);
VERIFY (ull <= a);
VERIFY (d32 <= a);
VERIFY (d64 <= a);
VERIFY (d128 <= a);
}
void
compare_gt_64 (void)
{
decimal64 a = 100;
VERIFY (a > si);
VERIFY (a > ui);
VERIFY (a > sl);
VERIFY (a > ul);
VERIFY (a > sll);
VERIFY (a > ull);
VERIFY (a > d32);
VERIFY (a > d64);
VERIFY (a > d128);
a = -100;
VERIFY (si > a);
VERIFY (ui > a);
VERIFY (sl > a);
VERIFY (ul > a);
VERIFY (sll > a);
VERIFY (ull > a);
VERIFY (d32 > a);
VERIFY (d64 > a);
VERIFY (d128 > a);
}
void
compare_ge_64 (void)
{
decimal64 a;
a = si; VERIFY (a >= si); VERIFY (si <= a);
a = ui; VERIFY (a >= ui); VERIFY (ui <= a);
a = sl; VERIFY (a >= sl); VERIFY (sl <= a);
a = ul; VERIFY (a >= ul); VERIFY (ul <= a);
a = sll; VERIFY (a >= sll); VERIFY (sll <= a);
a = ull; VERIFY (a >= ull); VERIFY (ull <= a);
a = d32; VERIFY (a >= d32); VERIFY (d32 <= a);
a = (decimal32)d64; VERIFY (a >= d64); VERIFY (d64 <= a);
a = (decimal32)d128; VERIFY (a >= d128); VERIFY (d128 <= a);
a = 100;
VERIFY (a >= si);
VERIFY (a >= ui);
VERIFY (a >= sl);
VERIFY (a >= ul);
VERIFY (a >= sll);
VERIFY (a >= ull);
VERIFY (a >= d32);
VERIFY (a >= d64);
VERIFY (a >= d128);
a = -100;
VERIFY (si >= a);
VERIFY (ui >= a);
VERIFY (sl >= a);
VERIFY (ul >= a);
VERIFY (sll >= a);
VERIFY (ull >= a);
VERIFY (d32 >= a);
VERIFY (d64 >= a);
VERIFY (d128 >= a);
}
void
compare_eq_128 (void)
{
decimal128 a;
a = si; VERIFY (a == si); VERIFY (si == a);
a = ui; VERIFY (a == ui); VERIFY (ui == a);
a = sl; VERIFY (a == sl); VERIFY (sl == a);
a = ul; VERIFY (a == ul); VERIFY (ul == a);
a = sll; VERIFY (a == sll); VERIFY (sll == a);
a = ull; VERIFY (a == ull); VERIFY (ull == a);
a = d32; VERIFY (a == d32); VERIFY (d32 == a);
a = d64; VERIFY (a == d64); VERIFY (d64 == a);
a = d128; VERIFY (a == d128); VERIFY (d128 == a);
}
void
compare_ne_128 (void)
{
decimal128 a = 100;
VERIFY (a != si); VERIFY (si != a);
VERIFY (a != ui); VERIFY (ui != a);
VERIFY (a != sl); VERIFY (sl != a);
VERIFY (a != ul); VERIFY (ul != a);
VERIFY (a != sll); VERIFY (sll != a);
VERIFY (a != ull); VERIFY (ull != a);
VERIFY (a != d32); VERIFY (d32 != a);
VERIFY (a != d64); VERIFY (d64 != a);
VERIFY (a != d128); VERIFY (d128 != a);
}
void
compare_lt_128 (void)
{
decimal128 a = -100;
VERIFY (a < si);
VERIFY (a < ui);
VERIFY (a < sl);
VERIFY (a < ul);
VERIFY (a < sll);
VERIFY (a < ull);
VERIFY (a < d32);
VERIFY (a < d64);
VERIFY (a < d128);
a = 100;
VERIFY (si < a);
VERIFY (ui < a);
VERIFY (sl < a);
VERIFY (ul < a);
VERIFY (sll < a);
VERIFY (ull < a);
VERIFY (d32 < a);
VERIFY (d64 < a);
VERIFY (d128 < a);
}
void
compare_le_128 (void)
{
decimal128 a;
a = si; VERIFY (a <= si); VERIFY (si <= a);
a = ui; VERIFY (a <= ui); VERIFY (ui <= a);
a = sl; VERIFY (a <= sl); VERIFY (sl <= a);
a = ul; VERIFY (a <= ul); VERIFY (ul <= a);
a = sll; VERIFY (a <= sll); VERIFY (sll <= a);
a = ull; VERIFY (a <= ull); VERIFY (ull <= a);
a = d32; VERIFY (a <= d32); VERIFY (d32 <= a);
a = (decimal32)d64; VERIFY (a <= d64); VERIFY (d64 <= a);
a = (decimal32)d128; VERIFY (a <= d128); VERIFY (d128 <= a);
a = -100;
VERIFY (a <= si);
VERIFY (a <= ui);
VERIFY (a <= sl);
VERIFY (a <= ul);
VERIFY (a <= sll);
VERIFY (a <= ull);
VERIFY (a <= d32);
VERIFY (a <= d64);
VERIFY (a <= d128);
a = 100;
VERIFY (si <= a);
VERIFY (ui <= a);
VERIFY (sl <= a);
VERIFY (ul <= a);
VERIFY (sll <= a);
VERIFY (ull <= a);
VERIFY (d32 <= a);
VERIFY (d64 <= a);
VERIFY (d128 <= a);
}
void
compare_gt_128 (void)
{
decimal128 a = 100;
VERIFY (a > si);
VERIFY (a > ui);
VERIFY (a > sl);
VERIFY (a > ul);
VERIFY (a > sll);
VERIFY (a > ull);
VERIFY (a > d32);
VERIFY (a > d64);
VERIFY (a > d128);
a = -100;
VERIFY (si > a);
VERIFY (ui > a);
VERIFY (sl > a);
VERIFY (ul > a);
VERIFY (sll > a);
VERIFY (ull > a);
VERIFY (d32 > a);
VERIFY (d64 > a);
VERIFY (d128 > a);
}
void
compare_ge_128 (void)
{
decimal128 a;
a = si; VERIFY (a >= si); VERIFY (si <= a);
a = ui; VERIFY (a >= ui); VERIFY (ui <= a);
a = sl; VERIFY (a >= sl); VERIFY (sl <= a);
a = ul; VERIFY (a >= ul); VERIFY (ul <= a);
a = sll; VERIFY (a >= sll); VERIFY (sll <= a);
a = ull; VERIFY (a >= ull); VERIFY (ull <= a);
a = d32; VERIFY (a >= d32); VERIFY (d32 <= a);
a = (decimal32)d64; VERIFY (a >= d64); VERIFY (d64 <= a);
a = (decimal32)d128; VERIFY (a >= d128); VERIFY (d128 <= a);
a = 100;
VERIFY (a >= si);
VERIFY (a >= ui);
VERIFY (a >= sl);
VERIFY (a >= ul);
VERIFY (a >= sll);
VERIFY (a >= ull);
VERIFY (a >= d32);
VERIFY (a >= d64);
VERIFY (a >= d128);
a = -100;
VERIFY (si >= a);
VERIFY (ui >= a);
VERIFY (sl >= a);
VERIFY (ul >= a);
VERIFY (sll >= a);
VERIFY (ull >= a);
VERIFY (d32 >= a);
VERIFY (d64 >= a);
VERIFY (d128 >= a);
}
int
main ()
{
compare_eq_32 ();
compare_ne_32 ();
compare_lt_32 ();
compare_le_32 ();
compare_gt_32 ();
compare_ge_32 ();
compare_eq_64 ();
compare_ne_64 ();
compare_lt_64 ();
compare_le_64 ();
compare_gt_64 ();
compare_ge_64 ();
compare_eq_128 ();
compare_ne_128 ();
compare_lt_128 ();
compare_le_128 ();
compare_gt_128 ();
compare_ge_128 ();
}

View File

@ -0,0 +1,250 @@
// Copyright (C) 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-require-effective-target-dfp }
// ISO/IEC TR 24733 3.2.2.6 Compound assignment (decimal32).
// ISO/IEC TR 24733 3.2.3.6 Compound assignment (decimal64).
// ISO/IEC TR 24733 3.2.4.6 Compound assignment (decimal128).
// Access member functions directly.
#include <decimal/decimal>
#include <testsuite_hooks.h>
using namespace std::decimal;
decimal32 d32 (5);
decimal64 d64 (-10);
decimal128 d128 (25);
int si = -2;
unsigned int ui = 5;
long sl = -10;
unsigned long ul = 20;
long long sll = -25;
unsigned long long ull = 50;
void
compound_assignment_add_32 (void)
{
decimal32 a (1000), b;
b = a; b.operator+=(d32); VERIFY (b == 1005);
b = a; b.operator+=(d64); VERIFY (b == 990);
b = a; b.operator+=(d128); VERIFY (b == 1025);
b = a; b.operator+=(si); VERIFY (b == 998);
b = a; b.operator+=(ui); VERIFY (b == 1005);
b = a; b.operator+=(sl); VERIFY (b == 990);
b = a; b.operator+=(ul); VERIFY (b == 1020);
b = a; b.operator+=(sll); VERIFY (b == 975);
b = a; b.operator+=(ull); VERIFY (b == 1050);
}
void
compound_assignment_subtract_32 (void)
{
decimal32 a (1000), b;
b = a; b.operator-=(d32); VERIFY (b == 995);
b = a; b.operator-=(d64); VERIFY (b == 1010);
b = a; b.operator-=(d128); VERIFY (b == 975);
b = a; b.operator-=(si); VERIFY (b == 1002);
b = a; b.operator-=(ui); VERIFY (b == 995);
b = a; b.operator-=(sl); VERIFY (b == 1010);
b = a; b.operator-=(ul); VERIFY (b == 980);
b = a; b.operator-=(sll); VERIFY (b == 1025);
b = a; b.operator-=(ull); VERIFY (b == 950);
}
void
compound_assignment_multiply_32 (void)
{
decimal32 a (1000), b;
b = a; b.operator*=(d32); VERIFY (b == 5000);
b = a; b.operator*=(d64); VERIFY (b == -10000);
b = a; b.operator*=(d128); VERIFY (b == 25000);
b = a; b.operator*=(si); VERIFY (b == -2000);
b = a; b.operator*=(ui); VERIFY (b == 5000);
b = a; b.operator*=(sl); VERIFY (b == -10000);
b = a; b.operator*=(ul); VERIFY (b == 20000);
b = a; b.operator*=(sll); VERIFY (b == -25000);
b = a; b.operator*=(ull); VERIFY (b == 50000);
}
void
compound_assignment_divide_32 (void)
{
decimal32 a (1000), b;
b = a; b.operator/=(d32); VERIFY (b == 200);
b = a; b.operator/=(d64); VERIFY (b == -100);
b = a; b.operator/=(d128); VERIFY (b == 40);
b = a; b.operator/=(si); VERIFY (b == -500);
b = a; b.operator/=(ui); VERIFY (b == 200);
b = a; b.operator/=(sl); VERIFY (b == -100);
b = a; b.operator/=(ul); VERIFY (b == 50);
b = a; b.operator/=(sll); VERIFY (b == -40);
b = a; b.operator/=(ull); VERIFY (b == 20);
}
void
compound_assignment_add_64 (void)
{
decimal64 a (1000), b;
b = a; b.operator+=(d32); VERIFY (b == 1005);
b = a; b.operator+=(d64); VERIFY (b == 990);
b = a; b.operator+=(d128); VERIFY (b == 1025);
b = a; b.operator+=(si); VERIFY (b == 998);
b = a; b.operator+=(ui); VERIFY (b == 1005);
b = a; b.operator+=(sl); VERIFY (b == 990);
b = a; b.operator+=(ul); VERIFY (b == 1020);
b = a; b.operator+=(sll); VERIFY (b == 975);
b = a; b.operator+=(ull); VERIFY (b == 1050);
}
void
compound_assignment_subtract_64 (void)
{
decimal64 a (1000), b;
b = a; b.operator-=(d32); VERIFY (b == 995);
b = a; b.operator-=(d64); VERIFY (b == 1010);
b = a; b.operator-=(d128); VERIFY (b == 975);
b = a; b.operator-=(si); VERIFY (b == 1002);
b = a; b.operator-=(ui); VERIFY (b == 995);
b = a; b.operator-=(sl); VERIFY (b == 1010);
b = a; b.operator-=(ul); VERIFY (b == 980);
b = a; b.operator-=(sll); VERIFY (b == 1025);
b = a; b.operator-=(ull); VERIFY (b == 950);
}
void
compound_assignment_multiply_64 (void)
{
decimal64 a (1000), b;
b = a; b.operator*=(d32); VERIFY (b == 5000);
b = a; b.operator*=(d64); VERIFY (b == -10000);
b = a; b.operator*=(d128); VERIFY (b == 25000);
b = a; b.operator*=(si); VERIFY (b == -2000);
b = a; b.operator*=(ui); VERIFY (b == 5000);
b = a; b.operator*=(sl); VERIFY (b == -10000);
b = a; b.operator*=(ul); VERIFY (b == 20000);
b = a; b.operator*=(sll); VERIFY (b == -25000);
b = a; b.operator*=(ull); VERIFY (b == 50000);
}
void
compound_assignment_divide_64 (void)
{
decimal64 a (1000), b;
b = a; b.operator/=(d32); VERIFY (b == 200);
b = a; b.operator/=(d64); VERIFY (b == -100);
b = a; b.operator/=(d128); VERIFY (b == 40);
b = a; b.operator/=(si); VERIFY (b == -500);
b = a; b.operator/=(ui); VERIFY (b == 200);
b = a; b.operator/=(sl); VERIFY (b == -100);
b = a; b.operator/=(ul); VERIFY (b == 50);
b = a; b.operator/=(sll); VERIFY (b == -40);
b = a; b.operator/=(ull); VERIFY (b == 20);
}
void
compound_assignment_add_128 (void)
{
decimal128 a (1000), b;
b = a; b.operator+=(d32); VERIFY (b == 1005);
b = a; b.operator+=(d64); VERIFY (b == 990);
b = a; b.operator+=(d128); VERIFY (b == 1025);
b = a; b.operator+=(si); VERIFY (b == 998);
b = a; b.operator+=(ui); VERIFY (b == 1005);
b = a; b.operator+=(sl); VERIFY (b == 990);
b = a; b.operator+=(ul); VERIFY (b == 1020);
b = a; b.operator+=(sll); VERIFY (b == 975);
b = a; b.operator+=(ull); VERIFY (b == 1050);
}
void
compound_assignment_subtract_128 (void)
{
decimal128 a (1000), b;
b = a; b.operator-=(d32); VERIFY (b == 995);
b = a; b.operator-=(d64); VERIFY (b == 1010);
b = a; b.operator-=(d128); VERIFY (b == 975);
b = a; b.operator-=(si); VERIFY (b == 1002);
b = a; b.operator-=(ui); VERIFY (b == 995);
b = a; b.operator-=(sl); VERIFY (b == 1010);
b = a; b.operator-=(ul); VERIFY (b == 980);
b = a; b.operator-=(sll); VERIFY (b == 1025);
b = a; b.operator-=(ull); VERIFY (b == 950);
}
void
compound_assignment_multiply_128 (void)
{
decimal128 a (1000), b;
b = a; b.operator*=(d32); VERIFY (b == 5000);
b = a; b.operator*=(d64); VERIFY (b == -10000);
b = a; b.operator*=(d128); VERIFY (b == 25000);
b = a; b.operator*=(si); VERIFY (b == -2000);
b = a; b.operator*=(ui); VERIFY (b == 5000);
b = a; b.operator*=(sl); VERIFY (b == -10000);
b = a; b.operator*=(ul); VERIFY (b == 20000);
b = a; b.operator*=(sll); VERIFY (b == -25000);
b = a; b.operator*=(ull); VERIFY (b == 50000);
}
void
compound_assignment_divide_128 (void)
{
decimal128 a (1000), b;
b = a; b.operator/=(d32); VERIFY (b == 200);
b = a; b.operator/=(d64); VERIFY (b == -100);
b = a; b.operator/=(d128); VERIFY (b == 40);
b = a; b.operator/=(si); VERIFY (b == -500);
b = a; b.operator/=(ui); VERIFY (b == 200);
b = a; b.operator/=(sl); VERIFY (b == -100);
b = a; b.operator/=(ul); VERIFY (b == 50);
b = a; b.operator/=(sll); VERIFY (b == -40);
b = a; b.operator/=(ull); VERIFY (b == 20);
}
int
main ()
{
compound_assignment_add_32 ();
compound_assignment_subtract_32 ();
compound_assignment_multiply_32 ();
compound_assignment_divide_32 ();
compound_assignment_add_64 ();
compound_assignment_subtract_64 ();
compound_assignment_multiply_64 ();
compound_assignment_divide_64 ();
compound_assignment_add_128 ();
compound_assignment_subtract_128 ();
compound_assignment_multiply_128 ();
compound_assignment_divide_128 ();
}

View File

@ -0,0 +1,248 @@
// Copyright (C) 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-require-effective-target-dfp }
// ISO/IEC TR 24733 3.2.2.6 Compound assignment (decimal32).
// ISO/IEC TR 24733 3.2.3.6 Compound assignment (decimal64).
// ISO/IEC TR 24733 3.2.4.6 Compound assignment (decimal128).
#include <decimal/decimal>
#include <testsuite_hooks.h>
using namespace std::decimal;
decimal32 d32 (5);
decimal64 d64 (-10);
decimal128 d128 (25);
int si = -2;
unsigned int ui = 5;
long sl = -10;
unsigned long ul = 20;
long long sll = -25;
unsigned long long ull = 50;
void
compound_assignment_add_32 (void)
{
decimal32 a (1000), b;
b = a; b += d32; VERIFY (b == 1005);
b = a; b += d64; VERIFY (b == 990);
b = a; b += d128; VERIFY (b == 1025);
b = a; b += si; VERIFY (b == 998);
b = a; b += ui; VERIFY (b == 1005);
b = a; b += sl; VERIFY (b == 990);
b = a; b += ul; VERIFY (b == 1020);
b = a; b += sll; VERIFY (b == 975);
b = a; b += ull; VERIFY (b == 1050);
}
void
compound_assignment_subtract_32 (void)
{
decimal32 a (1000), b;
b = a; b -= d32; VERIFY (b == 995);
b = a; b -= d64; VERIFY (b == 1010);
b = a; b -= d128; VERIFY (b == 975);
b = a; b -= si; VERIFY (b == 1002);
b = a; b -= ui; VERIFY (b == 995);
b = a; b -= sl; VERIFY (b == 1010);
b = a; b -= ul; VERIFY (b == 980);
b = a; b -= sll; VERIFY (b == 1025);
b = a; b -= ull; VERIFY (b == 950);
}
void
compound_assignment_multiply_32 (void)
{
decimal32 a (1000), b;
b = a; b *= d32; VERIFY (b == 5000);
b = a; b *= d64; VERIFY (b == -10000);
b = a; b *= d128; VERIFY (b == 25000);
b = a; b *= si; VERIFY (b == -2000);
b = a; b *= ui; VERIFY (b == 5000);
b = a; b *= sl; VERIFY (b == -10000);
b = a; b *= ul; VERIFY (b == 20000);
b = a; b *= sll; VERIFY (b == -25000);
b = a; b *= ull; VERIFY (b == 50000);
}
void
compound_assignment_divide_32 (void)
{
decimal32 a (1000), b;
b = a; b /= d32; VERIFY (b == 200);
b = a; b /= d64; VERIFY (b == -100);
b = a; b /= d128; VERIFY (b == 40);
b = a; b /= si; VERIFY (b == -500);
b = a; b /= ui; VERIFY (b == 200);
b = a; b /= sl; VERIFY (b == -100);
b = a; b /= ul; VERIFY (b == 50);
b = a; b /= sll; VERIFY (b == -40);
b = a; b /= ull; VERIFY (b == 20);
}
void
compound_assignment_add_64 (void)
{
decimal64 a (1000), b;
b = a; b += d32; VERIFY (b == 1005);
b = a; b += d64; VERIFY (b == 990);
b = a; b += d128; VERIFY (b == 1025);
b = a; b += si; VERIFY (b == 998);
b = a; b += ui; VERIFY (b == 1005);
b = a; b += sl; VERIFY (b == 990);
b = a; b += ul; VERIFY (b == 1020);
b = a; b += sll; VERIFY (b == 975);
b = a; b += ull; VERIFY (b == 1050);
}
void
compound_assignment_subtract_64 (void)
{
decimal64 a (1000), b;
b = a; b -= d32; VERIFY (b == 995);
b = a; b -= d64; VERIFY (b == 1010);
b = a; b -= d128; VERIFY (b == 975);
b = a; b -= si; VERIFY (b == 1002);
b = a; b -= ui; VERIFY (b == 995);
b = a; b -= sl; VERIFY (b == 1010);
b = a; b -= ul; VERIFY (b == 980);
b = a; b -= sll; VERIFY (b == 1025);
b = a; b -= ull; VERIFY (b == 950);
}
void
compound_assignment_multiply_64 (void)
{
decimal64 a (1000), b;
b = a; b *= d32; VERIFY (b == 5000);
b = a; b *= d64; VERIFY (b == -10000);
b = a; b *= d128; VERIFY (b == 25000);
b = a; b *= si; VERIFY (b == -2000);
b = a; b *= ui; VERIFY (b == 5000);
b = a; b *= sl; VERIFY (b == -10000);
b = a; b *= ul; VERIFY (b == 20000);
b = a; b *= sll; VERIFY (b == -25000);
b = a; b *= ull; VERIFY (b == 50000);
}
void
compound_assignment_divide_64 (void)
{
decimal64 a (1000), b;
b = a; b /= d32; VERIFY (b == 200);
b = a; b /= d64; VERIFY (b == -100);
b = a; b /= d128; VERIFY (b == 40);
b = a; b /= si; VERIFY (b == -500);
b = a; b /= ui; VERIFY (b == 200);
b = a; b /= sl; VERIFY (b == -100);
b = a; b /= ul; VERIFY (b == 50);
b = a; b /= sll; VERIFY (b == -40);
b = a; b /= ull; VERIFY (b == 20);
}
void
compound_assignment_add_128 (void)
{
decimal128 a (1000), b;
b = a; b += d32; VERIFY (b == 1005);
b = a; b += d64; VERIFY (b == 990);
b = a; b += d128; VERIFY (b == 1025);
b = a; b += si; VERIFY (b == 998);
b = a; b += ui; VERIFY (b == 1005);
b = a; b += sl; VERIFY (b == 990);
b = a; b += ul; VERIFY (b == 1020);
b = a; b += sll; VERIFY (b == 975);
b = a; b += ull; VERIFY (b == 1050);
}
void
compound_assignment_subtract_128 (void)
{
decimal128 a (1000), b;
b = a; b -= d32; VERIFY (b == 995);
b = a; b -= d64; VERIFY (b == 1010);
b = a; b -= d128; VERIFY (b == 975);
b = a; b -= si; VERIFY (b == 1002);
b = a; b -= ui; VERIFY (b == 995);
b = a; b -= sl; VERIFY (b == 1010);
b = a; b -= ul; VERIFY (b == 980);
b = a; b -= sll; VERIFY (b == 1025);
b = a; b -= ull; VERIFY (b == 950);
}
void
compound_assignment_multiply_128 (void)
{
decimal128 a (1000), b;
b = a; b *= d32; VERIFY (b == 5000);
b = a; b *= d64; VERIFY (b == -10000);
b = a; b *= d128; VERIFY (b == 25000);
b = a; b *= si; VERIFY (b == -2000);
b = a; b *= ui; VERIFY (b == 5000);
b = a; b *= sl; VERIFY (b == -10000);
b = a; b *= ul; VERIFY (b == 20000);
b = a; b *= sll; VERIFY (b == -25000);
b = a; b *= ull; VERIFY (b == 50000);
}
void
compound_assignment_divide_128 (void)
{
decimal128 a (1000), b;
b = a; b /= d32; VERIFY (b == 200);
b = a; b /= d64; VERIFY (b == -100);
b = a; b /= d128; VERIFY (b == 40);
b = a; b /= si; VERIFY (b == -500);
b = a; b /= ui; VERIFY (b == 200);
b = a; b /= sl; VERIFY (b == -100);
b = a; b /= ul; VERIFY (b == 50);
b = a; b /= sll; VERIFY (b == -40);
b = a; b /= ull; VERIFY (b == 20);
}
int
main ()
{
compound_assignment_add_32 ();
compound_assignment_subtract_32 ();
compound_assignment_multiply_32 ();
compound_assignment_divide_32 ();
compound_assignment_add_64 ();
compound_assignment_subtract_64 ();
compound_assignment_multiply_64 ();
compound_assignment_divide_64 ();
compound_assignment_add_128 ();
compound_assignment_subtract_128 ();
compound_assignment_multiply_128 ();
compound_assignment_divide_128 ();
}

View File

@ -0,0 +1,101 @@
// Copyright (C) 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-require-effective-target-dfp }
// ISO/IEC TR 24733 3.2.2.2 Conversion from floating-point type (decimal32).
// ISO/IEC TR 24733 3.2.3.2 Conversion from floating-point type (decimal64).
// ISO/IEC TR 24733 3.2.4.2 Conversion from floating-point type (decimal128).
#include <decimal/decimal>
#include <testsuite_hooks.h>
using namespace std::decimal;
void
conversion_from_float_32 ()
{
decimal32 d32(123);
decimal64 d64(234);
decimal128 d128(345);
float f = 456.F;
double d = 567.;
long double ld = 678.L;
d32 = (decimal32) d64;
VERIFY (d32 == make_decimal32 (234LL, 0));
d32 = (decimal32) d128;
VERIFY (d32 == make_decimal32 (345LL, 0));
d32 = (decimal32) f;
VERIFY (d32 == make_decimal32 (456LL, 0));
d32 = (decimal32) d;
VERIFY (d32 == make_decimal32 (567LL, 0));
d32 = (decimal32) ld;
VERIFY (d32 == make_decimal32 (678LL, 0));
}
void
conversion_from_float_64 ()
{
decimal32 d32(123);
decimal64 d64(234);
decimal128 d128(345);
float f = 456.F;
double d = 567.;
long double ld = 678.L;
d64 = d32;
VERIFY (d64 == make_decimal64 (123LL, 0));
d64 = (decimal64) d128;
VERIFY (d64 == make_decimal64 (345LL, 0));
d64 = (decimal64) f;
VERIFY (d64 == make_decimal64 (456LL, 0));
d64 = (decimal64) d;
VERIFY (d64 == make_decimal64 (567LL, 0));
d64 = (decimal64) ld;
VERIFY (d64 == make_decimal64 (678LL, 0));
}
void
conversion_from_float_128 ()
{
decimal32 d32(123);
decimal64 d64(234);
decimal128 d128(345);
float f = 456.F;
double d = 567.;
long double ld = 678.L;
d128 = d32;
VERIFY (d128 == make_decimal128 (123LL, 0));
d128 = d64;
VERIFY (d128 == make_decimal128 (234LL, 0));
d128 = (decimal128) f;
VERIFY (d128 == make_decimal128 (456LL, 0));
d128 = (decimal128) d;
VERIFY (d128 == make_decimal128 (567LL, 0));
d128 = (decimal128) ld;
VERIFY (d128 == make_decimal128 (678LL, 0));
}
int
main ()
{
conversion_from_float_32 ();
conversion_from_float_64 ();
conversion_from_float_128 ();
}

View File

@ -0,0 +1,193 @@
// Copyright (C) 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-require-effective-target-dfp }
// ISO/IEC TR 24733 3.2.2.3 Conversion from integral type (decimal32).
// ISO/IEC TR 24733 3.2.3.3 Conversion from integral type (decimal64).
// ISO/IEC TR 24733 3.2.4.3 Conversion from integral type (decimal128).
#include <decimal/decimal>
#include <testsuite_hooks.h>
using namespace std::decimal;
void
conversion_from_integral_p32 ()
{
decimal32 d;
decimal32 from_si (1);
decimal32 from_ui (2U);
decimal32 from_sl (3L);
decimal32 from_ul (4UL);
decimal32 from_sll (5LL);
decimal32 from_ull (6ULL);
d++; VERIFY (from_si == d);
d++; VERIFY (from_ui == d);
d++; VERIFY (from_sl == d);
d++; VERIFY (from_ul == d);
d++; VERIFY (from_sll == d);
d++; VERIFY (from_ull == d);
from_si = 7;
d++; VERIFY (from_si == d);
from_ui = 8U;
d++; VERIFY (from_ui == d);
from_sl = 9L;
d++; VERIFY (from_sl == d);
from_ul = 10UL;
d++; VERIFY (from_ul == d);
from_sll = 11LL;
d++; VERIFY (from_sll == d);
from_ull = 12ULL;
d++; VERIFY (from_ull == d);
}
void
conversion_from_integral_m32 ()
{
decimal32 d;
decimal32 from_si (-1);
decimal32 from_sl (-2L);
decimal32 from_sll (-3LL);
d--; VERIFY (from_si == d);
d--; VERIFY (from_sl == d);
d--; VERIFY (from_sll == d);
from_si = -4;
d--; VERIFY (from_si == d);
from_sl = -5L;
d--; VERIFY (from_sl == d);
from_sll = -6LL;
d--; VERIFY (from_sll == d);
}
void
conversion_from_integral_p64 ()
{
decimal64 d;
decimal64 from_si (1);
decimal64 from_ui (2U);
decimal64 from_sl (3L);
decimal64 from_ul (4UL);
decimal64 from_sll (5LL);
decimal64 from_ull (6ULL);
d++; VERIFY (from_si == d);
d++; VERIFY (from_ui == d);
d++; VERIFY (from_sl == d);
d++; VERIFY (from_ul == d);
d++; VERIFY (from_sll == d);
d++; VERIFY (from_ull == d);
from_si = 7;
d++; VERIFY (from_si == d);
from_ui = 8U;
d++; VERIFY (from_ui == d);
from_sl = 9L;
d++; VERIFY (from_sl == d);
from_ul = 10UL;
d++; VERIFY (from_ul == d);
from_sll = 11LL;
d++; VERIFY (from_sll == d);
from_ull = 12ULL;
d++; VERIFY (from_ull == d);
}
void
conversion_from_integral_m64 ()
{
decimal64 d;
decimal64 from_si (-1);
decimal64 from_sl (-2L);
decimal64 from_sll (-3LL);
d--; VERIFY (from_si == d);
d--; VERIFY (from_sl == d);
d--; VERIFY (from_sll == d);
from_si = -4;
d--; VERIFY (from_si == d);
from_sl = -5L;
d--; VERIFY (from_sl == d);
from_sll = -6LL;
d--; VERIFY (from_sll == d);
}
void
conversion_from_integral_p128 ()
{
decimal128 d;
decimal128 from_si (1);
decimal128 from_ui (2U);
decimal128 from_sl (3L);
decimal128 from_ul (4UL);
decimal128 from_sll (5LL);
decimal128 from_ull (6ULL);
d++; VERIFY (from_si == d);
d++; VERIFY (from_ui == d);
d++; VERIFY (from_sl == d);
d++; VERIFY (from_ul == d);
d++; VERIFY (from_sll == d);
d++; VERIFY (from_ull == d);
from_si = 7;
d++; VERIFY (from_si == d);
from_ui = 8U;
d++; VERIFY (from_ui == d);
from_sl = 9L;
d++; VERIFY (from_sl == d);
from_ul = 10UL;
d++; VERIFY (from_ul == d);
from_sll = 11LL;
d++; VERIFY (from_sll == d);
from_ull = 12ULL;
}
void
conversion_from_integral_m128 ()
{
decimal128 d;
decimal128 from_si (-1);
decimal128 from_sl (-2L);
decimal128 from_sll (-3LL);
d--; VERIFY (from_si == d);
d--; VERIFY (from_sl == d);
d--; VERIFY (from_sll == d);
from_si = -4;
d--; VERIFY (from_si == d);
from_sl = -5L;
d--; VERIFY (from_sl == d);
from_sll = -6LL;
d--; VERIFY (from_sll == d);
}
int
main ()
{
conversion_from_integral_p32 ();
conversion_from_integral_m32 ();
conversion_from_integral_p64 ();
conversion_from_integral_m64 ();
conversion_from_integral_p128 ();
conversion_from_integral_m128 ();
}

View File

@ -0,0 +1,105 @@
// Copyright (C) 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-require-effective-target-dfp }
// ISO/IEC TR 24733 3.2.6 Conversion to generic floating-point type.
#include <decimal/decimal>
#include <testsuite_hooks.h>
using namespace std::decimal;
void
conversion_to_generic_float_32 ()
{
std::decimal::decimal32 d32(123);
float f;
double d;
long double ld;
f = decimal32_to_float (d32);
VERIFY (f == 123.F);
d = decimal32_to_double (d32);
VERIFY (d == 123.);
ld = decimal32_to_long_double (d32);
VERIFY (ld == 123.L);
d32++;
f = decimal_to_float (d32);
VERIFY (f == 124.F);
d = decimal_to_double (d32);
VERIFY (d == 124.);
ld = decimal_to_long_double (d32);
VERIFY (ld == 124.L);
}
void
conversion_to_generic_float_64 ()
{
std::decimal::decimal64 d64(234);
float f;
double d;
long double ld;
f = decimal64_to_float (d64);
VERIFY (f == 234.F);
d = decimal64_to_double (d64);
VERIFY (d == 234.);
ld = decimal64_to_long_double (d64);
VERIFY (ld == 234.L);
d64++;
f = decimal_to_float (d64);
VERIFY (f == 235.F);
d = decimal_to_double (d64);
VERIFY (d == 235.);
ld = decimal_to_long_double (d64);
VERIFY (ld == 235.L);
}
void
conversion_to_generic_float_128 ()
{
std::decimal::decimal128 d128(345);
float f;
double d;
long double ld;
f = decimal128_to_float (d128);
VERIFY (f == 345.F);
d = decimal128_to_double (d128);
VERIFY (d == 345.);
ld = decimal128_to_long_double (d128);
VERIFY (ld == 345.L);
d128++;
f = decimal_to_float (d128);
VERIFY (f == 346.F);
d = decimal_to_double (d128);
VERIFY (d == 346.);
ld = decimal_to_long_double (d128);
VERIFY (ld == 346.L);
}
int
main ()
{
conversion_to_generic_float_32 ();
conversion_to_generic_float_64 ();
conversion_to_generic_float_128 ();
}

View File

@ -0,0 +1,85 @@
// Copyright (C) 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-require-effective-target-dfp }
// ISO/IEC TR 24733 3.2.2.4 Conversion to integral type (decimal32).
// ISO/IEC TR 24733 3.2.3.4 Conversion to integral type (decimal64).
// ISO/IEC TR 24733 3.2.4.4 Conversion to integral type (decimal128).
#include <decimal/decimal>
#include <climits>
#include <cstdio>
#include <testsuite_hooks.h>
// Use extension to replace implicit long long conversion with function call.
#define LONGLONG(X) decimal_to_long_long(X)
using namespace std::decimal;
void
conversion_to_integral_32 (void)
{
#undef MAXVAL
#define MAXVAL 999999LL
decimal32 a, b (1), c (-1), d (MAXVAL), e (-MAXVAL);
long long ll;
ll = LONGLONG (a); VERIFY (ll == 0LL);
ll = LONGLONG (b); VERIFY (ll == 1LL);
ll = LONGLONG (c); VERIFY (ll == -1LL);
ll = LONGLONG (d); VERIFY (ll == MAXVAL);
ll = LONGLONG (e); VERIFY (ll == -MAXVAL);
}
void
conversion_to_integral_64 (void)
{
#undef MAXVAL
#define MAXVAL 999999999999999LL
decimal64 a, b (1), c (-1), d (MAXVAL), e (-MAXVAL);
long long ll;
ll = LONGLONG (a); VERIFY (ll == 0LL);
ll = LONGLONG (b); VERIFY (ll == 1LL);
ll = LONGLONG (c); VERIFY (ll == -1LL);
ll = LONGLONG (d); VERIFY (ll == MAXVAL);
ll = LONGLONG (e); VERIFY (ll == -MAXVAL);
}
void
conversion_to_integral_128 (void)
{
#undef MAXVAL
#define MAXVAL LONG_LONG_MAX
decimal128 a, b (1), c (-1), d (MAXVAL), e (-MAXVAL);
long long ll;
ll = LONGLONG (a); VERIFY (ll == 0LL);
ll = LONGLONG (b); VERIFY (ll == 1LL);
ll = LONGLONG (c); VERIFY (ll == -1LL);
ll = LONGLONG (d); VERIFY (ll == MAXVAL);
ll = LONGLONG (e); VERIFY (ll == -MAXVAL);
}
int
main ()
{
conversion_to_integral_32 ();
conversion_to_integral_64 ();
conversion_to_integral_128 ();
}

View File

@ -0,0 +1,65 @@
// Copyright (C) 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-require-effective-target-dfp }
// ISO/IEC TR 24733 3.2.2.1 Construct/copy/destroy (decimal32).
// ISO/IEC TR 24733 3.2.3.1 Construct/copy/destroy (decimal64).
// ISO/IEC TR 24733 3.2.4.1 Construct/copy/destroy (decimal128).
// Test the default constructor.
#include <decimal/decimal>
#include <cstring>
#include <testsuite_hooks.h>
using namespace std::decimal;
void
ctor_32 (void)
{
decimal32 a;
float b __attribute__((mode(SD))) = 0.e-101DF;
VERIFY (memcmp (&a, &b, 4) == 0);
}
void
ctor_64 (void)
{
decimal64 a;
float b __attribute__((mode(DD))) = 0.e-398DD;
VERIFY (memcmp (&a, &b, 8) == 0);
}
void
ctor_128 (void)
{
decimal128 a;
float b __attribute__((mode(TD))) = 0.e-6176DL;
VERIFY (memcmp (&a, &b, 16) == 0);
}
int
main ()
{
ctor_32 ();
ctor_64 ();
ctor_128 ();
}

View File

@ -0,0 +1,181 @@
// Copyright (C) 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-require-effective-target-dfp }
// ISO/IEC TR 24733 3.2.2.5 Increment and decrement operators (decimal32).
// ISO/IEC TR 24733 3.2.3.5 Increment and decrement operators (decimal64).
// ISO/IEC TR 24733 3.2.4.5 Increment and decrement operators (decimal128).
// Access member functions directly.
#include <decimal/decimal>
#include <testsuite_hooks.h>
// Use extension to replace implicit long long conversion with function call.
#define LONGLONG(X) decimal_to_long_long(X)
using namespace std::decimal;
void
incdec32 (void)
{
int ival;
std::decimal::decimal32 a(11), b, c;
// Verify that we get the expected value of b after assignment.
b = a;
ival = LONGLONG (b); VERIFY (ival == 11);
// Check that the increment and decrement operators change the value
// of the original class.
b = a;
b.operator++();
ival = LONGLONG (b); VERIFY (ival == 12);
b = a;
b.operator++(1);
ival = LONGLONG (b); VERIFY (ival == 12);
b = a;
b.operator--();
ival = LONGLONG (b); VERIFY (ival == 10);
b = a;
b.operator--(1);
ival = LONGLONG (b); VERIFY (ival == 10);
// Check that the increment and decrement operators return the
// correct value.
b = a;
c = b.operator++();
ival = LONGLONG (c); VERIFY (ival == 12);
b = a;
c = b.operator++(1);
ival = LONGLONG (c); VERIFY (ival == 11);
b = a;
c = b.operator--();
ival = LONGLONG (c); VERIFY (ival == 10);
b = a;
c = b.operator--(1);
ival = LONGLONG (c); VERIFY (ival == 11);
}
void
incdec64 (void)
{
int ival;
std::decimal::decimal64 a(11), b, c;
// Verify that we get the expected value of b after assignment.
b = a;
ival = LONGLONG (b); VERIFY (ival == 11);
// Check that the increment and decrement operators change the value
// of the original class.
b = a;
b.operator++();
ival = LONGLONG (b); VERIFY (ival == 12);
b = a;
b.operator++(1);
ival = LONGLONG (b); VERIFY (ival == 12);
b = a;
b.operator--();
ival = LONGLONG (b); VERIFY (ival == 10);
b = a;
b.operator--(1);
ival = LONGLONG (b); VERIFY (ival == 10);
// Check that the increment and decrement operators return the
// correct value.
b = a;
c = b.operator++();
ival = LONGLONG (c); VERIFY (ival == 12);
b = a;
c = b.operator++(1);
ival = LONGLONG (c); VERIFY (ival == 11);
b = a;
c = b.operator--();
ival = LONGLONG (c); VERIFY (ival == 10);
b = a;
c = b.operator--(1);
ival = LONGLONG (c); VERIFY (ival == 11);
}
void
incdec128 (void)
{
int ival;
std::decimal::decimal128 a(11), b, c;
// Verify that we get the expected value of b after assignment.
b = a;
ival = LONGLONG (b); VERIFY (ival == 11);
// Check that the increment and decrement operators change the value
// of the original class.
b = a;
b.operator++();
ival = LONGLONG (b); VERIFY (ival == 12);
b = a;
b.operator++(1);
ival = LONGLONG (b); VERIFY (ival == 12);
b = a;
b.operator--();
ival = LONGLONG (b); VERIFY (ival == 10);
b = a;
b.operator--(1);
ival = LONGLONG (b); VERIFY (ival == 10);
// Check that the increment and decrement operators return the
// correct value.
b = a;
c = b.operator++();
ival = LONGLONG (c); VERIFY (ival == 12);
b = a;
c = b.operator++(1);
ival = LONGLONG (c); VERIFY (ival == 11);
b = a;
c = b.operator--();
ival = LONGLONG (c); VERIFY (ival == 10);
b = a;
c = b.operator--(1);
ival = LONGLONG (c); VERIFY (ival == 11);
}
int
main ()
{
incdec32 ();
incdec64 ();
incdec128 ();
}

View File

@ -0,0 +1,179 @@
// Copyright (C) 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-require-effective-target-dfp }
// ISO/IEC TR 24733 3.2.2.5 Increment and decrement operators (decimal32).
// ISO/IEC TR 24733 3.2.3.5 Increment and decrement operators (decimal64).
// ISO/IEC TR 24733 3.2.4.5 Increment and decrement operators (decimal128).
#include <decimal/decimal>
#include <testsuite_hooks.h>
// Use extension to replace implicit long long conversion with function call.
#define LONGLONG(X) decimal_to_long_long(X)
using namespace std::decimal;
void
incdec32 (void)
{
int ival;
std::decimal::decimal32 a(11), b, c;
// Verify that we get the expected value of b after assignment.
b = a;
ival = LONGLONG (b); VERIFY (ival == 11);
// Check that the increment and decrement operators change the value
// of the original class.
b = a;
++b;
ival = LONGLONG (b); VERIFY (ival == 12);
b = a;
b++;
ival = LONGLONG (b); VERIFY (ival == 12);
b = a;
--b;
ival = LONGLONG (b); VERIFY (ival == 10);
b = a;
b--;
ival = LONGLONG (b); VERIFY (ival == 10);
// Check that the increment and decrement operators return the
// correct value.
b = a;
c = ++b;
ival = LONGLONG (c); VERIFY (ival == 12);
b = a;
c = b++;
ival = LONGLONG (c); VERIFY (ival == 11);
b = a;
c = --b;
ival = LONGLONG (c); VERIFY (ival == 10);
b = a;
c = b--;
ival = LONGLONG (c); VERIFY (ival == 11);
}
void
incdec64 (void)
{
int ival;
std::decimal::decimal64 a(11), b, c;
// Verify that we get the expected value of b after assignment.
b = a;
ival = LONGLONG (b); VERIFY (ival == 11);
// Check that the increment and decrement operators change the value
// of the original class.
b = a;
++b;
ival = LONGLONG (b); VERIFY (ival == 12);
b = a;
b++;
ival = LONGLONG (b); VERIFY (ival == 12);
b = a;
--b;
ival = LONGLONG (b); VERIFY (ival == 10);
b = a;
b--;
ival = LONGLONG (b); VERIFY (ival == 10);
// Check that the increment and decrement operators return the
// correct value.
b = a;
c = ++b;
ival = LONGLONG (c); VERIFY (ival == 12);
b = a;
c = b++;
ival = LONGLONG (c); VERIFY (ival == 11);
b = a;
c = --b;
ival = LONGLONG (c); VERIFY (ival == 10);
b = a;
c = b--;
ival = LONGLONG (c); VERIFY (ival == 11);
}
void
incdec128 (void)
{
int ival;
std::decimal::decimal128 a(11), b, c;
// Verify that we get the expected value of b after assignment.
b = a;
ival = LONGLONG (b); VERIFY (ival == 11);
// Check that the increment and decrement operators change the value
// of the original class.
b = a;
++b;
ival = LONGLONG (b); VERIFY (ival == 12);
b = a;
b++;
ival = LONGLONG (b); VERIFY (ival == 12);
b = a;
--b;
ival = LONGLONG (b); VERIFY (ival == 10);
b = a;
b--;
ival = LONGLONG (b); VERIFY (ival == 10);
// Check that the increment and decrement operators return the
// correct value.
b = a;
c = ++b;
ival = LONGLONG (c); VERIFY (ival == 12);
b = a;
c = b++;
ival = LONGLONG (c); VERIFY (ival == 11);
b = a;
c = --b;
ival = LONGLONG (c); VERIFY (ival == 10);
b = a;
c = b--;
ival = LONGLONG (c); VERIFY (ival == 11);
}
int
main ()
{
incdec32 ();
incdec64 ();
incdec128 ();
}

View File

@ -0,0 +1,132 @@
// Copyright (C) 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-require-effective-target-dfp }
// ISO/IEC TR 24733 3.2.5 Initialization from coefficient and exponent.
#include <decimal/decimal>
#include <cstring>
#include <testsuite_hooks.h>
#define PASTE2(A,B) A ## B
#define PASTE(A,B) PASTE2(A,B)
#define TESTVAL_NEG(COEFF,ESIGN,EXP,SUF,NUM,SIZE) \
x = PASTE(PASTE(PASTE(PASTE(PASTE(COEFF,.),E),ESIGN),EXP),SUF); \
sll = PASTE(COEFF,LL); \
i = ESIGN EXP; \
a = PASTE(make_decimal,32) (sll, i); \
b = PASTE(make_decimal,32) (PASTE(COEFF,LL), ESIGN EXP); \
VERIFY ((__builtin_memcmp ((void *)&x, (void *)&a, SIZE) == 0) \
&& (__builtin_memcmp ((void *)&x, (void *)&b,SIZE) == 0));
#define TESTVAL_NONNEG(COEFF,ESIGN,EXP,SUF,NUM,SIZE) \
x = PASTE(PASTE(PASTE(PASTE(PASTE(COEFF,.),E),ESIGN),EXP),SUF); \
sll = PASTE(COEFF,LL); \
ull = PASTE(COEFF,ULL); \
i = ESIGN EXP; \
a = PASTE(make_decimal,32) (sll, i); \
b = PASTE(make_decimal,32) (PASTE(COEFF,LL), ESIGN EXP); \
c = PASTE(make_decimal,32) (ull, i); \
d = PASTE(make_decimal,32) (PASTE(COEFF,ULL), ESIGN EXP); \
VERIFY ((__builtin_memcmp ((void *)&x, (void *)&a, SIZE) == 0) \
&& (__builtin_memcmp ((void *)&x, (void *)&b,SIZE) == 0) \
&& (__builtin_memcmp ((void *)&x, (void *)&c,SIZE) == 0) \
&& (__builtin_memcmp ((void *)&x, (void *)&d,SIZE) == 0));
using namespace std::decimal;
void
make_decimal_32 (void)
{
decimal32 a, b, c, d;
float x __attribute__((mode(SD)));
int i;
unsigned long sz = sizeof (decimal32);
volatile long long sll;
volatile unsigned long long ull;
TESTVAL_NONNEG (0, +, 0, DF, 32, sz);
TESTVAL_NONNEG (5, +, 1, DF, 32, sz);
TESTVAL_NONNEG (50, +, 0, DF, 32, sz);
TESTVAL_NONNEG (500, +, 0, DF, 32, sz);
TESTVAL_NEG (-25, -, 3, DF, 32, sz)
TESTVAL_NEG (-500, +, 0, DF, 32, sz);
TESTVAL_NONNEG (999999, +, 91, DF, 32, sz);
TESTVAL_NONNEG (1, -, 9, DF, 32, sz);
TESTVAL_NONNEG (1, -, 90, DF, 32, sz);
TESTVAL_NONNEG (1, -, 95, DF, 32, sz);
TESTVAL_NONNEG (1, -, 101, DF, 32, sz);
TESTVAL_NEG (-1, -, 101, DF, 32, sz);
}
void
make_decimal_64 (void)
{
decimal64 a, b, c, d;
float x __attribute__((mode(DD)));
int i;
unsigned long sz = sizeof (decimal64);
volatile long long sll;
volatile unsigned long long ull;
TESTVAL_NONNEG (0, +, 0, DF, 64, sz);
TESTVAL_NONNEG (5, +, 1, DF, 64, sz);
TESTVAL_NONNEG (50, +, 0, DF, 64, sz);
TESTVAL_NONNEG (500, +, 0, DF, 64, sz);
TESTVAL_NEG (-25, -, 3, DF, 64, sz)
TESTVAL_NEG (-500, +, 0, DF, 64, sz);
TESTVAL_NONNEG (999999, +, 91, DF, 64, sz);
TESTVAL_NONNEG (1, -, 9, DF, 64, sz);
TESTVAL_NONNEG (1, -, 90, DF, 64, sz);
TESTVAL_NONNEG (1, -, 95, DF, 64, sz);
TESTVAL_NONNEG (1, -, 101, DF, 64, sz);
TESTVAL_NEG (-1, -, 101, DF, 64, sz);
}
void
make_decimal_128 (void)
{
decimal128 a, b, c, d;
float x __attribute__((mode(TD)));
int i;
unsigned long sz = sizeof (decimal128);
volatile long long sll;
volatile unsigned long long ull;
TESTVAL_NONNEG (0, +, 0, DF, 128, sz);
TESTVAL_NONNEG (5, +, 1, DF, 128, sz);
TESTVAL_NONNEG (50, +, 0, DF, 128, sz);
TESTVAL_NONNEG (500, +, 0, DF, 128, sz);
TESTVAL_NEG (-25, -, 3, DF, 128, sz)
TESTVAL_NEG (-500, +, 0, DF, 128, sz);
TESTVAL_NONNEG (999999, +, 91, DF, 128, sz);
TESTVAL_NONNEG (1, -, 9, DF, 128, sz);
TESTVAL_NONNEG (1, -, 90, DF, 128, sz);
TESTVAL_NONNEG (1, -, 95, DF, 128, sz);
TESTVAL_NONNEG (1, -, 101, DF, 128, sz);
TESTVAL_NEG (-1, -, 101, DF, 128, sz);
}
int
main ()
{
make_decimal_32 ();
make_decimal_64 ();
make_decimal_128 ();
}

View File

@ -0,0 +1,206 @@
// Copyright (C) 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-do compile }
// { dg-require-effective-target-dfp }
// Test that binary operators do not accept mixed decimal and generic
// floating-point operands. This isn't explicity prohibited in
// ISO/IEC TR 24733 but it is prohibited in C, and in C++ there should
// not be an implicit conversion from a decimal floating-point type to
// a generic floating-point type.
#include <decimal/decimal>
#include <testsuite_hooks.h>
using namespace std::decimal;
decimal32 a32, b32, c32;
decimal64 a64, b64, c64;
decimal128 a128, b128, c128;
float f;
double d;
long double ld;
bool b1, b2, b3, b4, b5, b6;
void
bad_add (void)
{
a32 = b32 + f; // { dg-error "error" }
a32 = ld + b32; // { dg-error "error" }
a64 = b64 + d; // { dg-error "error" }
a64 = ld + b64; // { dg-error "error" }
a128 = b128 + ld; // { dg-error "error" }
a128 = d + b128; // { dg-error "error" }
}
void
bad_subtract (void)
{
a32 = b32 - f; // { dg-error "error" }
a32 = ld - b32; // { dg-error "error" }
a64 = b64 - d; // { dg-error "error" }
a64 = ld - b64; // { dg-error "error" }
a128 = b128 - ld; // { dg-error "error" }
a128 = d - b128; // { dg-error "error" }
}
void
bad_multiply (void)
{
a32 = b32 * f; // { dg-error "error" }
a32 = ld * b32; // { dg-error "error" }
a64 = b64 * d; // { dg-error "error" }
a64 = ld * b64; // { dg-error "error" }
a128 = b128 * ld; // { dg-error "error" }
a128 = d * b128; // { dg-error "error" }
}
void
bad_divide (void)
{
a32 = b32 / f; // { dg-error "error" }
a32 = ld / b32; // { dg-error "error" }
a64 = b64 / d; // { dg-error "error" }
a64 = ld / b64; // { dg-error "error" }
a128 = b128 / ld; // { dg-error "error" }
a128 = d / b128; // { dg-error "error" }
}
void
bad_eq (void)
{
b1 = b32 == f; // { dg-error "error" }
b2 = ld == b32; // { dg-error "error" }
b3 = b64 == d; // { dg-error "error" }
b4 = ld == b64; // { dg-error "error" }
b5 = b128 == ld; // { dg-error "error" }
b6 = d == b128; // { dg-error "error" }
}
void
bad_ne (void)
{
b1 = b32 != f; // { dg-error "error" }
b2 = ld != b32; // { dg-error "error" }
b3 = b64 != d; // { dg-error "error" }
b4 = ld != b64; // { dg-error "error" }
b5 = b128 != ld; // { dg-error "error" }
b6 = d != b128; // { dg-error "error" }
}
void
bad_lt (void)
{
b1 = b32 < f; // { dg-error "error" }
b2 = ld < b32; // { dg-error "error" }
b3 = b64 < d; // { dg-error "error" }
b4 = ld < b64; // { dg-error "error" }
b5 = b128 < ld; // { dg-error "error" }
b6 = d < b128; // { dg-error "error" }
}
void
bad_le (void)
{
b1 = b32 <= f; // { dg-error "error" }
b2 = ld <= b32; // { dg-error "error" }
b3 = b64 <= d; // { dg-error "error" }
b4 = ld <= b64; // { dg-error "error" }
b5 = b128 <= ld; // { dg-error "error" }
b6 = d <= b128; // { dg-error "error" }
}
void
bad_gt (void)
{
b1 = b32 > f; // { dg-error "error" }
b2 = ld > b32; // { dg-error "error" }
b3 = b64 > d; // { dg-error "error" }
b4 = ld > b64; // { dg-error "error" }
b5 = b128 > ld; // { dg-error "error" }
b6 = d > b128; // { dg-error "error" }
}
void
bad_ge (void)
{
b1 = b32 >= f; // { dg-error "error" }
b2 = ld >= b32; // { dg-error "error" }
b3 = b64 >= d; // { dg-error "error" }
b4 = ld >= b64; // { dg-error "error" }
b5 = b128 >= ld; // { dg-error "error" }
b6 = d >= b128; // { dg-error "error" }
}
void
bad_pluseq (void)
{
a32 += f; // { dg-error "error" }
a32 += d; // { dg-error "error" }
a32 += ld; // { dg-error "error" }
a64 += f; // { dg-error "error" }
a64 += d; // { dg-error "error" }
a64 += ld; // { dg-error "error" }
a128 += f; // { dg-error "error" }
a128 += d; // { dg-error "error" }
a128 += ld; // { dg-error "error" }
}
void
bad_minuseq (void)
{
a32 -= f; // { dg-error "error" }
a32 -= d; // { dg-error "error" }
a32 -= ld; // { dg-error "error" }
a64 -= f; // { dg-error "error" }
a64 -= d; // { dg-error "error" }
a64 -= ld; // { dg-error "error" }
a128 -= f; // { dg-error "error" }
a128 -= d; // { dg-error "error" }
a128 -= ld; // { dg-error "error" }
}
void
bad_timeseq (void)
{
a32 *= f; // { dg-error "error" }
a32 *= d; // { dg-error "error" }
a32 *= ld; // { dg-error "error" }
a64 *= f; // { dg-error "error" }
a64 *= d; // { dg-error "error" }
a64 *= ld; // { dg-error "error" }
a128 *= f; // { dg-error "error" }
a128 *= d; // { dg-error "error" }
a128 *= ld; // { dg-error "error" }
}
void
bad_divideeq (void)
{
a32 /= f; // { dg-error "error" }
a32 /= d; // { dg-error "error" }
a32 /= ld; // { dg-error "error" }
a64 /= f; // { dg-error "error" }
a64 /= d; // { dg-error "error" }
a64 /= ld; // { dg-error "error" }
a128 /= f; // { dg-error "error" }
a128 /= d; // { dg-error "error" }
a128 /= ld; // { dg-error "error" }
}
// { dg-excess-errors "notes about candidates" }

View File

@ -0,0 +1,160 @@
// Copyright (C) 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-do compile }
// { dg-require-effective-target-dfp }
// Test that C++ binary operators that are restricted to integer operands
// do not accept decimal float operands.
#include <decimal/decimal>
using namespace std::decimal;
decimal32 a32, b32, c32;
decimal64 a64, b64, c64;
decimal128 a128, b128, c128;
void
modulus (void)
{
a32 = b32 % c32; // { dg-error "error" }
a64 = b64 % c64; // { dg-error "error" }
a128 = b128 % c128; // { dg-error "error" }
a128 = b32 % c128; // { dg-error "error" }
a128 = b64 % c128; // { dg-error "error" }
a32 = 100 % c32; // { dg-error "error" }
a64 = 10 % c64; // { dg-error "error" }
a128 = 1000 % c128; // { dg-error "error" }
a32 = b32 % 7; // { dg-error "error" }
a64 = b64 % 5; // { dg-error "error" }
a128 = b128 % 3; // { dg-error "error" }
}
void
bitwise_right_shift (void)
{
a32 = b32 >> c32; // { dg-error "error" }
a64 = b64 >> c64; // { dg-error "error" }
a128 = b128 >> c128; // { dg-error "error" }
a128 = b32 >> c128; // { dg-error "error" }
a128 = b64 >> c128; // { dg-error "error" }
a32 = 100 >> c32; // { dg-error "error" }
a64 = 10 >> c64; // { dg-error "error" }
a128 = 1000 >> c128; // { dg-error "error" }
a32 = b32 >> 7; // { dg-error "error" }
a64 = b64 >> 5; // { dg-error "error" }
a128 = b128 >> 3; // { dg-error "error" }
}
void
bitwise_left_shift (void)
{
a32 = b32 << c32; // { dg-error "error" }
a64 = b64 << c64; // { dg-error "error" }
a128 = b128 << c128; // { dg-error "error" }
a128 = b32 << c128; // { dg-error "error" }
a128 = b64 << c128; // { dg-error "error" }
a32 = 100 << c32; // { dg-error "error" }
a64 = 10 << c64; // { dg-error "error" }
a128 = 1000 << c128; // { dg-error "error" }
a32 = b32 << 7; // { dg-error "error" }
a64 = b64 << 5; // { dg-error "error" }
a128 = b128 << 3; // { dg-error "error" }
}
void
bitwise_exclusive_or (void)
{
a32 = b32 ^ c32; // { dg-error "error" }
a64 = b64 ^ c64; // { dg-error "error" }
a128 = b128 ^ c128; // { dg-error "error" }
a128 = b32 ^ c128; // { dg-error "error" }
a128 = b64 ^ c128; // { dg-error "error" }
a32 = 100 ^ c32; // { dg-error "error" }
a64 = 10 ^ c64; // { dg-error "error" }
a128 = 1000 ^ c128; // { dg-error "error" }
a32 = b32 ^ 7; // { dg-error "error" }
a64 = b64 ^ 5; // { dg-error "error" }
a128 = b128 ^ 3; // { dg-error "error" }
}
void
bitwise_inclusive_or (void)
{
a32 = b32 | c32; // { dg-error "error" }
a64 = b64 | c64; // { dg-error "error" }
a128 = b128 | c128; // { dg-error "error" }
a128 = b32 | c128; // { dg-error "error" }
a128 = b64 | c128; // { dg-error "error" }
a32 = 100 | c32; // { dg-error "error" }
a64 = 10 | c64; // { dg-error "error" }
a128 = 1000 | c128; // { dg-error "error" }
a32 = b32 | 7; // { dg-error "error" }
a64 = b64 | 5; // { dg-error "error" }
a128 = b128 | 3; // { dg-error "error" }
}
void
logical_and (void)
{
a32 = b32 && c32; // { dg-error "error" }
a64 = b64 && c64; // { dg-error "error" }
a128 = b128 && c128; // { dg-error "error" }
a128 = b32 && c128; // { dg-error "error" }
a128 = b64 && c128; // { dg-error "error" }
a32 = 100 && c32; // { dg-error "error" }
a64 = 10 && c64; // { dg-error "error" }
a128 = 1000 && c128; // { dg-error "error" }
a32 = b32 && 7; // { dg-error "error" }
a64 = b64 && 5; // { dg-error "error" }
a128 = b128 && 3; // { dg-error "error" }
}
void
logical_or (void)
{
a32 = b32 || c32; // { dg-error "error" }
a64 = b64 || c64; // { dg-error "error" }
a128 = b128 || c128; // { dg-error "error" }
a128 = b32 || c128; // { dg-error "error" }
a128 = b64 || c128; // { dg-error "error" }
a32 = 100 || c32; // { dg-error "error" }
a64 = 10 || c64; // { dg-error "error" }
a128 = 1000 || c128; // { dg-error "error" }
a32 = b32 || 7; // { dg-error "error" }
a64 = b64 || 5; // { dg-error "error" }
a128 = b128 || 3; // { dg-error "error" }
}
void
bitwise_complement (void)
{
a32 = ~b32; // { dg-error "error" }
a64 = ~b64; // { dg-error "error" }
a128 = ~b128; // { dg-error "error" }
}
void
logical_not (void)
{
a32 = !b32; // { dg-error "error" }
a64 = !b64; // { dg-error "error" }
a128 = !b128; // { dg-error "error" }
}
// { dg-excess-errors "" { target *-*-* } }

View File

@ -0,0 +1,93 @@
// Copyright (C) 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// { dg-require-effective-target-dfp }
// ISO/IEC TR 24733 3.2.7 Unary arithmetic operators.
#include <decimal/decimal>
#include <testsuite_hooks.h>
using namespace std::decimal;
decimal32 a32 (20), b32 (-20);
decimal64 a64 (124), b64 (-124);
decimal128 a128 (5001), b128 (-5001);
void
unary_plus_32 (void)
{
decimal32 a;
a = +a32; VERIFY (a == a32);
a = +b32; VERIFY (a == b32);
}
void
unary_minus_32 (void)
{
decimal32 a;
a = -a32; VERIFY (a == b32);
a = -b32; VERIFY (a == a32);
}
void
unary_plus_64 (void)
{
decimal64 a;
a = +a64; VERIFY (a == a64);
a = +b64; VERIFY (a == b64);
}
void
unary_minus_64 (void)
{
decimal64 a;
a = -a64; VERIFY (a == b64);
a = -b64; VERIFY (a == a64);
}
void
unary_plus_128 (void)
{
decimal128 a;
a = +a128; VERIFY (a == a128);
a = +b128; VERIFY (a == b128);
}
void
unary_minus_128 (void)
{
decimal128 a;
a = -a128; VERIFY (a == b128);
a = -b128; VERIFY (a == a128);
}
int main ()
{
unary_plus_32 ();
unary_minus_32 ();
unary_plus_64 ();
unary_minus_64 ();
unary_plus_128 ();
unary_minus_128 ();
}

View File

@ -58,6 +58,7 @@ if {[info exists tests_file] && [file exists $tests_file]} {
lappend subdirs "$srcdir/ext"
lappend subdirs "$srcdir/performance"
lappend subdirs "$srcdir/tr1"
lappend subdirs "$srcdir/decimal"
verbose "subdirs are $subdirs"
# Find all the tests.