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

Rounding in NumberFormatter #2399

Merged
merged 2 commits into from
Nov 26, 2021
Merged

Rounding in NumberFormatter #2399

merged 2 commits into from
Nov 26, 2021

Conversation

oleibman
Copy link
Collaborator

Fix #2385. NumberFormatter is using sprintf on a float, and is seeing inconsistent rounding as a result (it will also occasionally result in -0). Change to round the number before presenting it to sprintf.

This is:

- [x] a bugfix
- [ ] a new feature

Checklist:

Why this change is needed?

Fix PHPOffice#2385. NumberFormatter is using sprintf on a float, and is seeing inconsistent rounding as a result (it will also occasionally result in `-0`). Change to round the number before presenting it to sprintf.
@nohn
Copy link
Contributor

nohn commented Feb 4, 2022

Tests that seem to provoke that strange rounding behaviour are in https://github.com/nohn/PhpSpreadsheet/tree/strange_rounding_format_value_with_mask

Run with those tests failing: https://github.com/nohn/PhpSpreadsheet/actions/runs/1795815772

@oleibman oleibman deleted the roundfmt branch February 6, 2022 04:40
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.

Loaded excel file didn't round decimal value correctly.
2 participants