|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #77451 %g format for printf & sprintf is misdocumented
Submitted: 2019-01-12 18:26 UTC Modified: 2019-02-12 23:15 UTC
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: markamery at btinternet dot com Assigned: cmb (profile)
Status: Verified Package: Strings related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2019-01-12 18:26 UTC] markamery at btinternet dot com
At, the %g specifier is documented as follows:

    shorter of %e and %f.

This isn't true. %g often uses scientific notation even though it'd be shorter not to, and what's more, its output may differ from BOTH %e and %f, since it strips trailing zeros and %f and %e don't.

See where I explore this point at length.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-01-14 04:44 UTC]
-Summary: %g specifier to printf is misdocumented +Summary: %g format for printf & sprintf is misdocumented -Status: Open +Status: Verified -Package: Documentation problem +Package: Strings related -Operating System: N/A +Operating System:
 [2019-01-14 04:44 UTC]
Thanks for noticing this, you can also submit a patch to fix the documentation by using the online editor located at
 [2019-02-12 20:43 UTC]
-Assigned To: +Assigned To: girgias
 [2019-02-12 23:15 UTC]
-Assigned To: girgias +Assigned To: cmb
 [2019-02-12 23:15 UTC]
Wrote a patch to improve the sprintf doc:

@cmb I was thinking to maybe move the examples out of the format parameter
and then move the format parameter XML into an entity and include this entity in all the other related functions (such as printf or fscanf for example).

Oh also I couldn't try it out as I haven't managed to download the Doc Block Rendering system onto my Linux Sub System so not totally sure how this patch looks like.
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Feb 23 00:01:25 2019 UTC