Skip to content

Fix GH-18897: printf: empty precision is interpreted as precision 6, not as precision 0 - #18912

Merged
ndossche merged 2 commits into
php:masterfrom
ndossche:fix-18897
Jun 24, 2025
Merged

Fix GH-18897: printf: empty precision is interpreted as precision 6, not as precision 0#18912
ndossche merged 2 commits into
php:masterfrom
ndossche:fix-18897

Conversation

@ndossche

Copy link
Copy Markdown
Member

Like in other languages, and especially C where printf originates from, a missing precision should be treated as a 0 precision. Because the ADJ_PRECISION flag was not set, the double formatting code resetted the precision to the default float precision of 6.

Targeting master because of the behavioural BC break.

@bukkabukka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, please add also note to UPGRADING

…6, not as precision 0
Like in other languages, and especially C where printf originates from,
a missing precision should be treated as a 0 precision.
Because the ADJ_PRECISION flag was not set, the double formatting code
resetted the precision to the default float precision of 6.
@ndossche
ndossche merged commit 5ed8b2b into php:masterJun 24, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

printf: empty precision is interpreted as precision 6, not as precision 0

3 participants

@ndossche@bukka@TimWolla