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

fmt: inconsistency in 0 padded formatting of Inf and Nan float values #14421

martisch opened this issue Feb 20, 2016 · 4 comments

fmt: inconsistency in 0 padded formatting of Inf and Nan float values #14421

martisch opened this issue Feb 20, 2016 · 4 comments


Copy link

@martisch martisch commented Feb 20, 2016

For e.g. "%020f" Inf is not 0 padded but NaN is.


There is no test case for 0 padded NaN (but for Inf) and it seems this behavior has existed throughout Go 1.x .
C does not 0 pad NaN and Infs which seemed the reason the Infs are treated special in Go too.

This might not be changed anymore due to the Go 1 guarantees but the API documentation does not seem to explicitly mention the treatment for NaN or Inf either.

Not sure if it should just be document or if this should be fixed for 1.7 
If ok i can submit a patch that just adds a test case for current Go behavior with a comment that references this issue or make the treatment of NaN consistent with Inf.
Copy link

@robpike robpike commented Feb 20, 2016

It's just saying, "Oooooh, a Nan!".

Might be a consequence of or might be old. Should be easy to fix regardless.

Copy link

@minux minux commented Feb 20, 2016

Copy link
Contributor Author

@martisch martisch commented Feb 21, 2016

Writing the patch that rob mentioned made me aware of the NaN case.
I write a patch to fix the NaN case now.
Just wanted to make sure its ok to correct and does not break any Go 1.x guarantees. But since Inf only changed in 1.3 i guess its ok to make them consistent.

Copy link

@gopherbot gopherbot commented Feb 21, 2016

CL mentions this issue.

@gopherbot gopherbot closed this in 5dc053b Feb 21, 2016
@golang golang locked and limited conversation to collaborators Feb 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.