This is the mail archive of the mailing list for the eCos project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug 1001628] New: %g printf format prints more digits than expected

Please do not reply to this email. Use the web interface provided at:

           Summary: %g printf format prints more digits than expected
           Product: eCos
           Version: CVS
          Platform: All
        OS/Version: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: low
         Component: C library
             Class: Advice Request

Created an attachment (id=1841)
 --> (
a proposed patch to fix this defect

when a printf format like "%.7g" is used, you would expect
to see at most 7 valid decimals. But if the value is very close
to an integer like (float)5.000123 the output may look like "5.000123xxxx"
with xxxx = 4 additional digits which contain only rounding errors.
The correct output would be "5.000123", which is 7 valid digits.

The reason is in "language/c/libc/stdio/current/src/output/vfnprintf.cxx",
where the loop termination assumes the number of leading digits (in expcnt)
to be zero, which is not always the case however.

To fix this use the attached patch file.
The patch also introduces an additional test case in
which will only succeed when the printf format is output correctly.

Configure bugmail:
------- You are receiving this mail because: -------
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]