Skip to content

Add Decimal.prototype.closeTo(value, delta) for approximate equality checks #257

@gonzaotc

Description

@gonzaotc

No built-in method exists to check approximate equality. Current workaround:

a.minus(b).abs().lte(delta)

Proposed:

Decimal(1.00000001).closeTo(Decimal(1), 0.00000001) // true

Feel free to change the function name, the point is to simplify approximation assertions :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions