printf negative zero inconsistency
Open
Nobody has claimed this yet.
Bug
Status: Needs Triage
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
Description
The following code:
<?php
var_dump(sprintf('%.2f%%', -0.0));
var_dump(sprintf('%.2f%%', -0.001));
Resulted in this output:
string(5) "0.00%"
string(6) "-0.00%"
But I expected this output instead:
string(5) "0.00%"
string(5) "0.00%"
PHP Version
any
Operating System
any
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the discrepancy from the issue's sprintf example and compare the handling of -0.0 and -0.001 in the PHP interpreter's formatting path. Trace the sprintf implementation to identify where the sign is retained, then add regression coverage showing the expected output for both values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100