You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The special precision -1 uses the smallest number of digits necessary such that ParseFloat will return f exactly.
The documentation doesn't say that FormatFloat will print the most precise decimal approximation. What it does say is that it'll output just enough digits so that ParseFloat will return f exactly.
What version of Go are you using (
go version
)?1.7
What operating system and processor architecture are you using (
go env
)?Playground
What did you do?
strconv.FormatFloat(38.675, 'f', -1, 64)
https://play.golang.org/p/r2SL1x_Uu6
What did you expect to see?
38.675 doesn't have an exact float64 representation; I expected 38.6749999999999971578290569595992565155029296875.
What did you see instead?
38.675
The text was updated successfully, but these errors were encountered: