diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gcc.dg/dfp/convert-dfp-round.c | |
download | cbb-gcc-4.6.4-15d2061ac0796199866debe9ac87130894b0cdd3.tar.bz2 cbb-gcc-4.6.4-15d2061ac0796199866debe9ac87130894b0cdd3.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gcc.dg/dfp/convert-dfp-round.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/dfp/convert-dfp-round.c | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/dfp/convert-dfp-round.c b/gcc/testsuite/gcc.dg/dfp/convert-dfp-round.c new file mode 100644 index 000000000..e3781bfc9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/dfp/convert-dfp-round.c @@ -0,0 +1,124 @@ +/* { dg-options "-O0" } */ +/* { dg-skip-if "test is for emulation" { hard_dfp } { "*" } { "" } } */ + +/* N1150 5.2: Conversions among decimal floating types and between + decimal floating types and generic floating types. + C99 6.3.1.5(3) New. + + Perform conversions between DFP types in which the assigned value + cannot be represented exactly in the result and must be rounded + correctly according to the current rounding mode. + + Normally this would not be part of compiler testing, but conversions + are currently handled in libgcc via decNumber. */ + +#include "dfp-dbg.h" +#include "dfp-round.h" + +_Decimal32 d32; +_Decimal64 d64; +_Decimal128 d128; + +_Decimal32 d64_to_d32 (_Decimal64 d) { return d; } +_Decimal64 d128_to_d64 (_Decimal128 d) { return d; } +_Decimal32 d128_to_d32 (_Decimal128 d) { return d; } + +int +do_d64_to_d32 (_Decimal64 orig, _Decimal32 exp) +{ + d64 = orig; + d32 = d64_to_d32 (d64); + return (d32 == exp); +} + +int +do_d128_to_d32 (_Decimal128 orig, _Decimal32 exp) +{ + d128 = orig; + d32 = d128_to_d32 (d128); + return (d32 == exp); +} + +int +do_d128_to_d64 (_Decimal128 orig, _Decimal64 exp) +{ + d128 = orig; + d64 = d128_to_d64 (d128); + return (d64 == exp); +} + +int +main () +{ + DFP_SETROUND (FE_DEC_DOWNWARD); + if (!do_d64_to_d32 (1.1111125dd, 1.111112df)) FAILURE + if (!do_d64_to_d32 (1.1111135dd, 1.111113df)) FAILURE + if (!do_d64_to_d32 (-1.1111125dd, -1.111113df)) FAILURE + if (!do_d64_to_d32 (-1.1111135dd, -1.111114df)) FAILURE + if (!do_d128_to_d32 (1.1111125dl, 1.111112df)) FAILURE + if (!do_d128_to_d32 (1.1111135dl, 1.111113df)) FAILURE + if (!do_d128_to_d32 (-1.1111125dl, -1.111113df)) FAILURE + if (!do_d128_to_d32 (-1.1111135dl, -1.111114df)) FAILURE + if (!do_d128_to_d64 (1.1111111111111125dl, 1.111111111111112dd)) FAILURE + if (!do_d128_to_d64 (1.1111111111111135dl, 1.111111111111113dd)) FAILURE + if (!do_d128_to_d64 (-1.1111111111111125dl, -1.111111111111113dd)) FAILURE + if (!do_d128_to_d64 (-1.1111111111111135dl, -1.111111111111114dd)) FAILURE + + DFP_SETROUND (FE_DEC_TONEAREST); + if (!do_d64_to_d32 (1.1111125dd, 1.111112df)) FAILURE + if (!do_d64_to_d32 (1.1111135dd, 1.111114df)) FAILURE + if (!do_d64_to_d32 (-1.1111125dd, -1.111112df)) FAILURE + if (!do_d64_to_d32 (-1.1111135dd, -1.111114df)) FAILURE + if (!do_d128_to_d32 (1.1111125dl, 1.111112df)) FAILURE + if (!do_d128_to_d32 (1.1111135dl, 1.111114df)) FAILURE + if (!do_d128_to_d32 (-1.1111125dl, -1.111112df)) FAILURE + if (!do_d128_to_d32 (-1.1111135dl, -1.111114df)) FAILURE + if (!do_d128_to_d64 (1.1111111111111125dl, 1.111111111111112dd)) FAILURE + if (!do_d128_to_d64 (1.1111111111111135dl, 1.111111111111114dd)) FAILURE + if (!do_d128_to_d64 (-1.1111111111111125dl, -1.111111111111112dd)) FAILURE + if (!do_d128_to_d64 (-1.1111111111111135dl, -1.111111111111114dd)) FAILURE + + DFP_SETROUND (FE_DEC_TONEARESTFROMZERO); + if (!do_d64_to_d32 (1.1111125dd, 1.111113df)) FAILURE + if (!do_d64_to_d32 (1.1111135dd, 1.111114df)) FAILURE + if (!do_d64_to_d32 (-1.1111125dd, -1.111113df)) FAILURE + if (!do_d64_to_d32 (-1.1111135dd, -1.111114df)) FAILURE + if (!do_d128_to_d32 (1.1111125dl, 1.111113df)) FAILURE + if (!do_d128_to_d32 (1.1111135dl, 1.111114df)) FAILURE + if (!do_d128_to_d32 (-1.1111125dl, -1.111113df)) FAILURE + if (!do_d128_to_d32 (-1.1111135dl, -1.111114df)) FAILURE + if (!do_d128_to_d64 (1.1111111111111125dl, 1.111111111111113dd)) FAILURE + if (!do_d128_to_d64 (1.1111111111111135dl, 1.111111111111114dd)) FAILURE + if (!do_d128_to_d64 (-1.1111111111111125dl, -1.111111111111113dd)) FAILURE + if (!do_d128_to_d64 (-1.1111111111111135dl, -1.111111111111114dd)) FAILURE + + DFP_SETROUND (FE_DEC_TOWARDZERO); + if (!do_d64_to_d32 (1.1111125dd, 1.111112df)) FAILURE + if (!do_d64_to_d32 (1.1111135dd, 1.111113df)) FAILURE + if (!do_d64_to_d32 (-1.1111125dd, -1.111112df)) FAILURE + if (!do_d64_to_d32 (-1.1111135dd, -1.111113df)) FAILURE + if (!do_d128_to_d32 (1.1111125dl, 1.111112df)) FAILURE + if (!do_d128_to_d32 (1.1111135dl, 1.111113df)) FAILURE + if (!do_d128_to_d32 (-1.1111125dl, -1.111112df)) FAILURE + if (!do_d128_to_d32 (-1.1111135dl, -1.111113df)) FAILURE + if (!do_d128_to_d64 (1.1111111111111125dl, 1.111111111111112dd)) FAILURE + if (!do_d128_to_d64 (1.1111111111111135dl, 1.111111111111113dd)) FAILURE + if (!do_d128_to_d64 (-1.1111111111111125dl, -1.111111111111112dd)) FAILURE + if (!do_d128_to_d64 (-1.1111111111111135dl, -1.111111111111113dd)) FAILURE + + DFP_SETROUND (FE_DEC_UPWARD); + if (!do_d64_to_d32 (1.1111125dd, 1.111113df)) FAILURE + if (!do_d64_to_d32 (1.1111135dd, 1.111114df)) FAILURE + if (!do_d64_to_d32 (-1.1111125dd, -1.111112df)) FAILURE + if (!do_d64_to_d32 (-1.1111135dd, -1.111113df)) FAILURE + if (!do_d128_to_d32 (1.1111125dl, 1.111113df)) FAILURE + if (!do_d128_to_d32 (1.1111135dl, 1.111114df)) FAILURE + if (!do_d128_to_d32 (-1.1111125dl, -1.111112df)) FAILURE + if (!do_d128_to_d32 (-1.1111135dl, -1.111113df)) FAILURE + if (!do_d128_to_d64 (1.1111111111111125dl, 1.111111111111113dd)) FAILURE + if (!do_d128_to_d64 (1.1111111111111135dl, 1.111111111111114dd)) FAILURE + if (!do_d128_to_d64 (-1.1111111111111125dl, -1.111111111111112dd)) FAILURE + if (!do_d128_to_d64 (-1.1111111111111135dl, -1.111111111111113dd)) FAILURE + + FINISH +} |