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

Decimal numbers have rounding error #57

Open
mightybyte opened this issue Dec 12, 2021 · 0 comments · May be fixed by #58
Open

Decimal numbers have rounding error #57

mightybyte opened this issue Dec 12, 2021 · 0 comments · May be fixed by #58

Comments

@mightybyte
Copy link

The aeson package uses Scientific which avoids numeric instability from floating point numbers. This package uses Double, and that causes its behavior to diverge from that of aeson when dealing with decimal numbers. Here's an example ghci session that illustrates the issue:

λ fromRight "error" (Data.Aeson.eitherDecode "{\"foo\": 0.1}") :: Data.Aeson.Value
Object (fromList [("foo",Number 0.1)])
λ fromRight "error" (Data.YAML.Aeson.decode1Strict "foo: 0.1") :: Data.Aeson.Value
Object (fromList [("foo",Number 0.1000000000000000055511151231257827021181583404541015625)])

Would you be willing to accept a pull request that solves this problem? If so, any pointers as to what solution you'd prefer?

@mightybyte mightybyte changed the title Use Scientific instead of Double Decimal numbers have rounding error Dec 12, 2021
@sjakobi sjakobi linked a pull request May 11, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants