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

strconv: FormatFloat(x, 'g', -1, 64) does not give the most precise decimal approximation #2625

Closed
remyoudompheng opened this issue Dec 28, 2011 · 3 comments
Milestone

Comments

@remyoudompheng
Copy link
Contributor

What steps will reproduce the problem?
1. compile and run

package main

import "strconv"
import "fmt"

func main() {
    fmt.Println(strconv.FormatFloat(383260575764816448, 'g', -1, 64))
}


What is the expected output?

3.8326057576481645e+17

What do you see instead?

3.8326057576481644e+17

Which compiler are you using (5g, 6g, 8g, gccgo)?

6g

Which operating system are you using?

linux

Which revision are you using?  (hg identify)

c956aa39a269 (tip)

Please provide any additional information below.

The obtained result has the same length and can be parsed to the same float64 as the
expected result. However, it is not the closest possible to the original float
(5988446496325257p+6).
@adg
Copy link
Contributor

adg commented Jan 4, 2012

Comment 1:

Labels changed: added priority-later, packagebug, removed priority-triage.

Status changed to HelpWanted.

@rsc
Copy link
Contributor

rsc commented Jan 9, 2012

Comment 2:

Labels changed: added priority-go1, removed priority-later.

@rsc
Copy link
Contributor

rsc commented Jan 12, 2012

Comment 3:

This issue was closed by revision 6f77cd2.

Status changed to Fixed.

@rsc rsc added this to the Go1 milestone Apr 10, 2015
@rsc rsc removed the priority-go1 label Apr 10, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
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

4 participants