Skip to content

[Biug] Fix tolerance checks for IEEE-754 zero handling#28

Open
dacozai wants to merge 2 commits into
rust-cv:mainfrom
dacozai:bug/fix-incorrect-logic
Open

[Biug] Fix tolerance checks for IEEE-754 zero handling#28
dacozai wants to merge 2 commits into
rust-cv:mainfrom
dacozai:bug/fix-incorrect-logic

Conversation

@dacozai
Copy link
Copy Markdown

@dacozai dacozai commented Nov 21, 2025

Fix tolerance checks for IEEE-754 zero handling

Issue: #25

Rust f32/f64 follow IEEE-754, which defines both +0.0 and −0.0.
Because the previous code used is_positive() / is_negative(), values like +0.0 incorrectly passed checks that were intended to reject zero.

This PR updates all tolerance validations to use numeric comparisons instead of sign-bit checks:

  • Parameters documented as “panic if < 0” now use:

    assert!(x >= F::zero())
  • Parameters documented as “panic if ≤ 0” now use:

    assert!(x > F::zero())

This makes behaviour consistent with the documentation and eliminates IEEE-754 sign-bit edge cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant