Skip to content

Decimal numbers have rounding error #57

@mightybyte

Description

@mightybyte

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?

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