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: extraneous + printing with %0f #8217

Closed
gopherbot opened this issue Jun 16, 2014 · 11 comments
Closed

fmt: extraneous + printing with %0f #8217

gopherbot opened this issue Jun 16, 2014 · 11 comments
Milestone

Comments

@gopherbot
Copy link

by oliver.eilhard:

What does 'go version' print?
go version go1.3rc2 linux/amd64

What steps reproduce the problem?
Link: http://play.golang.org/p/6WFe3GJJVS

1. Run the program above with go 1.2.2
2. Run the program again with go 1.3rc2
3. Notice the differences in output.

What happened?
Go 1.2.2 prints:
<input type="hidden" name="NEW_ITEM-PRICE[1]"
value="00000000015.780"/>

Go 1.3rc2 prints:
<input type="hidden" name="NEW_ITEM-PRICE[1]"
value="&#43;0000000015.780"/>

What should have happened instead?
Go 1.3rc2 should print the same as Go 1.2.2:
<input type="hidden" name="NEW_ITEM-PRICE[1]"
value="00000000015.780"/>
@gopherbot
Copy link
Author

Comment 1 by oliver.eilhard:

Dan Kortschak added on go-nuts:
It was introduced in:
changeset:   20036:e8b79e17dc85 
user:        Rob Pike <r...@golang.org> 
date:        Wed May 21 12:30:43 2014 -0700 
summary:     fmt: fix floating-point padding once and for all

@kortschak
Copy link
Contributor

Comment 2:

Simple reproducer: http://play.golang.org/p/xI8QZCb_-w

@kortschak
Copy link
Contributor

Comment 3:

I'm working on this, but I'd like to know whether the correct behaviours for the
following two cases are:
"%07.2f", 1 + 2i -> "(0001.00+002.00i)"
"%07.2f", 1.0 -> "0001.00"

@ianlancetaylor
Copy link
Contributor

Comment 4:

Labels changed: added repo-main, release-go1.4.

@robpike
Copy link
Contributor

robpike commented Jun 16, 2014

Comment 5:

package main
import "fmt"
func main() {
    fmt.Printf("%015.3f", 1.0)
}
is all you need.

@robpike
Copy link
Contributor

robpike commented Jun 16, 2014

Comment 6:

Owner changed to @robpike.

@gopherbot
Copy link
Author

Comment 7:

CL https://golang.org/cl/103480043 mentions this issue.

@robpike
Copy link
Contributor

robpike commented Jun 17, 2014

Comment 8:

This issue was closed by revision b559392.

Status changed to Fixed.

@gopherbot
Copy link
Author

Comment 9:

CL https://golang.org/cl/110040043 mentions this issue.

@gopherbot
Copy link
Author

Comment 10:

CL https://golang.org/cl/105310043 mentions this issue.

@adg
Copy link
Contributor

adg commented Jun 18, 2014

Comment 11:

This issue was closed by revision 6b9d2b9bb54e.

@rsc rsc added this to the Go1.4 milestone Apr 14, 2015
@rsc rsc removed the release-go1.4 label Apr 14, 2015
adg added a commit that referenced this issue May 11, 2015
««« CL 103480043 / 777dd5a434db
fmt: fix signs when zero padding.
Bug was introduced recently. Add more tests, fix the bugs.
Suppress + sign when not required in zero padding.
Do not zero pad infinities.
All old tests still pass.
This time for sure!
Fixes #8217.

LGTM=rsc
R=golang-codereviews, dan.kortschak, rsc
CC=golang-codereviews
https://golang.org/cl/103480043
»»»

LGTM=r, rsc
R=r, rsc
CC=golang-codereviews
https://golang.org/cl/110040043
@golang golang locked and limited conversation to collaborators Jun 25, 2016
wheatman pushed a commit to wheatman/go-akaros that referenced this issue Jun 25, 2018
Bug was introduced recently. Add more tests, fix the bugs.
Suppress + sign when not required in zero padding.
Do not zero pad infinities.
All old tests still pass.
This time for sure!
Fixes golang#8217.

LGTM=rsc
R=golang-codereviews, dan.kortschak, rsc
CC=golang-codereviews
https://golang.org/cl/103480043
@rsc rsc unassigned robpike Jun 23, 2022
This issue was closed.
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

6 participants