Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with prepending zero in percentage -10<n<-9 #3921

Merged
merged 1 commit into from
Feb 28, 2024

Conversation

nicholasruunu
Copy link
Contributor

@nicholasruunu nicholasruunu commented Feb 27, 2024

This is:

- [x] a bugfix
- [ ] a new feature
- [ ] refactoring
- [ ] additional unit tests

Checklist:

  • Changes are covered by unit tests
    • Changes are covered by existing unit tests
    • New unit tests have been added
  • Code style is respected
  • Commit message explains why the change is made (see https://github.com/erlang/otp/wiki/Writing-good-commit-messages)
  • CHANGELOG.md contains a short summary of the change and a link to the pull request if applicable
  • Documentation is updated as necessary

Why this change is needed?

Before it was a bug when flooring negative numbers added to the length of the number for the sprintf mask.
For example -0.091 becomes -9.1 in percentage, floors to -10 which is going to increase $wholePartSize by 1 and add a leading zero to the result: -09.1% with format 0.0%. This happened for the whole range -10<n<-9 and I guess it would also happen for -100<n<-99 etc.

Fixes #3920

@nicholasruunu nicholasruunu marked this pull request as draft February 27, 2024 12:58
@nicholasruunu nicholasruunu force-pushed the hotfix/prepending-zero-prc branch 4 times, most recently from 5173716 to b8d58d3 Compare February 27, 2024 15:30
@nicholasruunu nicholasruunu marked this pull request as ready for review February 27, 2024 15:38
@nicholasruunu nicholasruunu force-pushed the hotfix/prepending-zero-prc branch 2 times, most recently from 0de3ed8 to aa640bb Compare February 27, 2024 16:04
@nicholasruunu nicholasruunu changed the title Fix issue with prepending zero in percentage -1.0<n<-0.9 Fix issue with prepending zero in percentage -10<n<-9 Feb 27, 2024
@nicholasruunu nicholasruunu force-pushed the hotfix/prepending-zero-prc branch from aa640bb to f4c4072 Compare February 27, 2024 16:41
CHANGELOG.md Outdated Show resolved Hide resolved
Before it was a bug when flooring negative numbers added to the length of
the number for the sprintf mask.
For example -0.091 becomes -9.1 in percentage, floors to -10 which is going to
increase $wholePartSize by 1 and add a leading zero to the result: -09.1% with
format 0.0%.
This happened for negative ranges where floor will increse the length of
the original number.
@nicholasruunu nicholasruunu force-pushed the hotfix/prepending-zero-prc branch from f4c4072 to c1d141b Compare February 27, 2024 22:31
@oleibman oleibman added this pull request to the merge queue Feb 28, 2024
Merged via the queue into PHPOffice:master with commit d09120d Feb 28, 2024
14 checks passed
@oleibman
Copy link
Collaborator

Thank you for your contribution.

@nicholasruunu
Copy link
Contributor Author

Thank you for your contribution.

No problem, thank you for the fast merge. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Prepending zero on negative percentage numbers -10<n<-9
2 participants