Document that hexfloat 'a'/'A' always emits the 0x prefix#4862
Merged
Conversation
vitaut
approved these changes
Jul 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The documentation for the
a/A(hexfloat) type indoc/syntax.mdis inaccurate in two ways:1.8p+1, without the0xprefix.#flag "adds a0xprefix".Both are wrong. In practice fmt always emits the
0xprefix (matching printf's%a), regardless of#.Reproduction
Output:
fmt : [0x1.8p+1]
fmt # : [0x1.8p+1] // 0x present with and without #
fmt : [0x1p+1]
fmt # : [0x1.p+1] // # forces a decimal point, not the prefix
std : [1.8p+1] // std::format omits the prefix
So:
0xprefix is always emitted, like printf's%a(and unlikestd::format).#flag forces a decimal point, not the prefix.Fix
Update the
arow to use the example0x1.8p+1, note that the0xprefix is always emitted, and correct the description of#. The implementation is correct; only the docs are updated to match it.Fixes #4657