Skip to content

feat: add relative tolerance for numeric assertions #4870

@thomhurst

Description

@thomhurst

Description

ToleranceBasedEqualsAssertion exists for double, float, decimal, DateTime, etc., but only supports absolute tolerance. Missing:

  • Relative tolerance (e.g., "within 5% of expected value")
  • Significant digits for decimal
  • Combined absolute + relative tolerance

Why

Financial calculations and scientific applications need different tolerance semantics. Relative tolerance is critical for comparing very large or very small numbers.

Suggested Approach

Extend with overloads like:

.WithinRelativeTolerance(double percentTolerance)
.WithinSignificantDigits(int digits)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions