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: String format %+d treats zero as a positive number #13326

Closed
mcmil opened this issue Nov 19, 2015 · 1 comment
Closed

fmt: String format %+d treats zero as a positive number #13326

mcmil opened this issue Nov 19, 2015 · 1 comment

Comments

@mcmil
Copy link

mcmil commented Nov 19, 2015

Formatting zero using the + flag in fmt.Printf("%+d",0) results in +0 output. It seems that it is a bug, since zero is neither positive nor negative. I would expect a simple 0 as an answer.

Sample: http://play.golang.org/p/XhcQmGYXMC

@robpike
Copy link
Contributor

robpike commented Nov 19, 2015

Working as intended. As the documentation says:

+   always print a sign for numeric values

You can argue whether 0 is positive, but you can't argue that it's not numeric.

@robpike robpike closed this as completed Nov 19, 2015
@golang golang locked and limited conversation to collaborators Nov 18, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants