Bug 35712 - decimal float literal constant zero loses significant trailing zeroes
Summary: decimal float literal constant zero loses significant trailing zeroes
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.3.2
Assignee: Janis Johnson
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2008-03-26 23:57 UTC by Janis Johnson
Modified: 2009-06-26 18:23 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-09-11 16:55:59


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Janis Johnson 2008-03-26 23:57:23 UTC
Decimal floating point types support significant trailing zeroes to
specify how much precision a value has.  Trailing zeroes are relevant
even for values of zero; for example, rounding 1.e-11dd to 10 places
after the decimal point results in 0.e-10dd.

The draft Technical Report N1241 for ISO/IEC TR 24732 doesn't specify
this directly, but section 9.5 "Formatted input/output specifiers"
shows expected output for five different representations of zero:
0, -0, 0.000000, 0e-07, and 0e+02.

Currently GCC converts all decimal float literal values of zero to
0.DF, 0.DD, or 0.DL.

I'm testing a patch to fix this but want a PR to record the issue.
Comment 1 Janis Johnson 2008-04-03 23:50:19 UTC
Subject: Bug 35712

Author: janis
Date: Thu Apr  3 23:49:35 2008
New Revision: 133881

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133881
Log:
2008-04-03  Janis Johnson  <janis187@us.ibm.com>

gcc/
	PR c/35712
	* dfp.c (decimal_from_decnumber): Retain trailing zeroes for
	  decimal-float literal constant zero.

testsuite/
	PR c/35712
	* gcc.dg/dfp/constants-zero.c: New test.


Added:
    trunk/gcc/testsuite/gcc.dg/dfp/constants-zero.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/dfp.c
    trunk/gcc/testsuite/ChangeLog

Comment 2 Peter Bergner 2008-06-23 19:59:07 UTC
Janis, is this fixed so we can close this bugzilla?
Comment 3 Janis Johnson 2008-09-11 16:56:51 UTC
Fixed in mainline.  It's not a regression so the fix has not been applied to 4.3.
Comment 4 Janis Johnson 2008-09-18 18:35:21 UTC
Subject: Bug 35712

Author: janis
Date: Thu Sep 18 18:33:58 2008
New Revision: 140466

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=140466
Log:
	Backport from mainline:
	2008-04-03  Janis Johnson  <janis187@us.ibm.com>
gcc/
	PR c/35712
	* dfp.c (decimal_from_decnumber): Retain trailing zeroes for
	decimal-float literal constant zero.
testsuite/
	PR c/35712
	* gcc.dg/dfp/constants-zero.c: New test.

Added:
    branches/gcc-4_3-branch/gcc/testsuite/gcc.dg/dfp/constants-zero.c
Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/dfp.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog