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

tpl: Fix bad rounding in NumFmt #7117

Merged
merged 1 commit into from
Jun 2, 2020
Merged

tpl: Fix bad rounding in NumFmt #7117

merged 1 commit into from
Jun 2, 2020

Conversation

sams96
Copy link
Contributor

@sams96 sams96 commented Apr 1, 2020

strconv.FormatFloat doesn't round properly sometimes, this adds a different method of rounding, fixes #7116

strconv.FormatFloat doesn't round properly sometimes, this adds a
different method of rounding, fixes gohugoio#7116
@moorereason
Copy link
Contributor

@bep, this PR looks good. Rounding floats is hard, especially with configurable precision. The approach taken here by @sams96 is the simplest all-around solution. It's not bulletproof since it can overflow at n*exp, but solving that in a general way is not at all trivial.

The Travis CI builds originally failed to run properly. I've restarted them. Once they're green, we should be clear to merge. 👍

@bep bep merged commit 3d9235e into gohugoio:master Jun 2, 2020
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lang.NumFmt Numbers greater than or equal to 5 are not rounded up correctly
3 participants