**Document:** WG14 N1492

**Submitter:** Fred J. Tydeman (USA)

**Submission Date:** 2010-06-17

**Related documents:** DR 319

**Subject:** Fix for DR 319 (printf("%a", 1.0) and
trailing zeros)

Defect Report 319 has a suggested change to which the committee said: The Committee does not believe this is a defect, however the Committee may consider establishing a rule for removing or not removing trailing zeros at some point in the future.

The issue:

Given that **FLT_RADIX** is 2, what is the output of:

double x = 1.0; printf("%a", x);In particular, are trailing zeros removed or kept? Different implementations do different things.

The fix:

Change **7.20.6.1 The fprintf function** sections as
follows.

Paragraph 6 on the '**#**' flag, change to: "For **a**,
**A**, **g** and **G** conversions, trailing zeros
are *not* removed from the result."

The above adds **a** and **A** to the existing **g**
and **G**.

Paragraph 8, section **a,A**, change to: "... if the
precision is missing and **FLT_RADIX** is a power of 2,
then the precision is the minimum sufficient for an exact
representation of all values of type **double** (unless
the **#** flag is used, any trailing zeros are removed
from the fraction portion of the result); ..."

The above adds the phrase in ().

Paragraph 8, section **a,A**, change to: "... if the
precision is missing and **FLT_RADIX** is not a power of
2, then the precision is the minimum sufficient to
distinguish values of type **double** (unless the **#**
flag is used, any trailing zeros are removed from the
fraction portion of the result); ..."

The above adds the phrase in () in place of "except that trailing zeros may be omitted".

Also, update the corresponding sections for the wide
character versions of the functions in **7.27.2.1 The
fwprintf function**.

Add to the Rationale in section 7.19.6.1: **%a** (without
an explicit precision) acts like **%g** (removes trailing
zeros or not, depending upon #), while **%.*a** (with an
explicit precision) acts like **%e** (keeps trailing
zeros). This was done to make implementations have same
behavior.

Update DR 319 to point to this document.