From d2da4af2c7872e1d9892cc5b3792d10dd86782a4 Mon Sep 17 00:00:00 2001 From: Janis Johnson Date: Thu, 17 Sep 2009 17:07:24 +0000 Subject: re PR c/41049 (conversion from integer to decimal float loses trailing zeros) gcc/ PR c/41049 * real.c decimal_from_integer, decimal_integer_string): New. (real_from_integer): Use them as special case for decimal float. * config/dfp-bit.c (_si_to_sd, _usi_to_sd): Use default rounding. (_di_to_sd, _di_to_dd, _di_to_td, _udi_to_sd, _udi_to_dd, _udi_to_td): Do not append zero after the decimal point in string to convert. gcc/testsuite/ PR c/41049 * dfp/pr41049.c: New test. From-SVN: r151806 --- gcc/config/dfp-bit.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'gcc/config/dfp-bit.c') diff --git a/gcc/config/dfp-bit.c b/gcc/config/dfp-bit.c index d315d5b..19f2fda 100644 --- a/gcc/config/dfp-bit.c +++ b/gcc/config/dfp-bit.c @@ -568,7 +568,6 @@ INT_TO_DFP (INT_TYPE i) decContext context; decContextDefault (&context, DEC_INIT_DECIMAL128); - context.round = DEC_ROUND_DOWN; f64 = *DEC_FLOAT_FROM_INT (&f64, i); u32.f = *decSingleFromWider (&u32.f, &f64, &context); if (DFP_EXCEPTIONS_ENABLED && context.status != 0) @@ -593,7 +592,7 @@ INT_TO_DFP (INT_TYPE i) DFP_INIT_ROUNDMODE (context.round); /* Use a C library function to get a floating point string. */ - sprintf (buf, INT_FMT ".0", CAST_FOR_FMT(i)); + sprintf (buf, INT_FMT ".", CAST_FOR_FMT(i)); /* Convert from the floating point string to a decimal* type. */ FROM_STRING (&s, buf, &context); IEEE_TO_HOST (s, &f); -- cgit v1.1