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

Floating point rounding #39923

wangcheng711 opened this issue Jun 29, 2020 · 1 comment

Floating point rounding #39923

wangcheng711 opened this issue Jun 29, 2020 · 1 comment


Copy link

@wangcheng711 wangcheng711 commented Jun 29, 2020

go version go1.14.4 windows/amd64

i := fmt.Sprintf("%.3f", 2981.2275)
fmt.Println(i) //2981.227
i = fmt.Sprintf("%.3f", 2981.2285)
fmt.Println(i) //2981.229
i = fmt.Sprintf("%.3f", 2973.9485)
fmt.Println(i) //2973.948
i = fmt.Sprintf("%.3f", 2973.9475)
fmt.Println(i) //2973.948

Copy link

@randall77 randall77 commented Jun 29, 2020

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For asking questions, see:

  • Stack Overflow with questions tagged "go"
  • The Go Forum, a web-based forum
  • Gophers Slack, use the invite app for access. The #general channel is a good starting point.
  • Go Community on Hashnode with questions and posts tagged with "go"
  • The golang-nuts mailing list
  • IRC channel #go-nuts on Freenode

If such a discussion concludes that this is a bug in Go, come back here and post a full issue report.

@randall77 randall77 closed this Jun 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

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