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

float32 values like 0.99 are formatted incorrectly #352

Closed
prashantv opened this issue Mar 28, 2018 · 1 comment
Closed

float32 values like 0.99 are formatted incorrectly #352

prashantv opened this issue Mar 28, 2018 · 1 comment

Comments

@prashantv
Copy link
Contributor

prashantv commented Mar 28, 2018

While updating to the latest version, I noticed that float32 values like 0.01 and 0.99 are now formatted incorrectly.

E..g, test failure output for 0.99

-       weight: 0.99
+       weight: 0.9900000095367432

I think this is related to #314

I'm working on a fix.

@prashantv
Copy link
Contributor Author

Here's a playground showing how formatting float32 as float32 gives the correct result, but formatting a float32 as a float64 causes incorrect results:
https://play.golang.org/p/jbseI1ivyMW

prashantv added a commit to prashantv/yaml that referenced this issue Mar 28, 2018
Currently, all float values are formatted using 64-bit, but that
incorrectly formats float32 values like 0.01 and 0.99.

See https://play.golang.org/p/jbseI1ivyMW for more context.

Fixes go-yaml#352.
@prashantv prashantv changed the title flaot32 values like 0.99 are formatted incorrectly float32 values like 0.99 are formatted incorrectly Mar 28, 2018
niemeyer pushed a commit that referenced this issue Mar 28, 2018
Currently, all float values are formatted using 64-bit, but that
incorrectly formats float32 values like 0.01 and 0.99.

See https://play.golang.org/p/jbseI1ivyMW for more context.

Fixes #352.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant