Skip to content

Inexact construction of Decimal from float #85

@barucden

Description

@barucden
julia> Decimal(0.1)
0.1

julia> Decimal(big(0.1))
0.1000000000000000055511151231257827021181583404541015625

This is problematic because then

julia> x = 0.1
0.1

julia> y = Decimal(x)
0.1

julia> x == y
true

julia> hash(x) == hash(y)
false

It can be improved:

julia> z = Decimal(big(0.1))
0.1000000000000000055511151231257827021181583404541015625

julia> hash(x) == hash(z)
true

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions