Skip to content

Use tolerance-based comparison for floating-point equality #12

@wendellmva

Description

@wendellmva

Description

AreEqual uses == for double comparison which can cause floating-point precision issues.

Current Code

return Convert.ToDouble(left) == Convert.ToDouble(right);

Solution

Use tolerance-based comparison:

Math.Abs(Convert.ToDouble(left) - Convert.ToDouble(right)) < 1e-10

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low priority/Nice to haveSP:11 story point (trivial)bugBug fixtemplatesCode templates

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions