Skip to content

strconv: FormatFloat(38.675, 'f', -1, 64) does not give the most precise decimal approximation #17997

@mrwonko

Description

@mrwonko

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions