Skip to content

Comments

BUG: Math::Absolute(-0.0) should return "plus zero" (+0.0)#5809

Merged
hjmjohnson merged 1 commit intoInsightSoftwareConsortium:mainfrom
N-Dekker:AbsoluteMinusZero
Feb 17, 2026
Merged

BUG: Math::Absolute(-0.0) should return "plus zero" (+0.0)#5809
hjmjohnson merged 1 commit intoInsightSoftwareConsortium:mainfrom
N-Dekker:AbsoluteMinusZero

Conversation

@N-Dekker
Copy link
Contributor

@N-Dekker N-Dekker commented Feb 17, 2026

Adjusted Absolute(T) to ensure that Absolute(-0.0) returns +0.0.

Added a unit test, AbsoluteMinusZeroReturnsPlusZero.

@N-Dekker N-Dekker requested a review from hjmjohnson February 17, 2026 13:01
@github-actions github-actions bot added type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct area:Core Issues affecting the Core module labels Feb 17, 2026
Copy link
Member

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😄

Of course, it needs to pass before merging.

@N-Dekker
Copy link
Contributor Author

N-Dekker commented Feb 17, 2026

Of course, it needs to pass before merging.

I'm doing TDD 😃


Update: Yes, it's failing!

At https://open.cdash.org/tests/2407046144

/.../ITK/Modules/Core/Common/test/itkMathGTest.cxx:367: Failure
Value of: std::signbit(absoluteValue)
  Actual: true
Expected: false

Copy link
Member

@hjmjohnson hjmjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@N-Dekker Thank you! If this fails/does not fail, I think the test is good. The fix is good, also. I'll keep an eye on this today, hopefully, and resolve this corner case soon.

@hjmjohnson
Copy link
Member

@N-Dekker I don't think there is a need for all the tests to fail. A sufficient number have demonstrated the problem that the fix and be included now.

569 - itkMath.AbsoluteMinusZeroReturnsPlusZero (Failed)

@N-Dekker
Copy link
Contributor Author

@hjmjohnson No worries, I'm preparing a fix (to be proposed). 😇

Adjusted `Absolute(T)` to ensure that `Absolute(-0.0)` returns `+0.0`.

Added a unit test, `AbsoluteMinusZeroReturnsPlusZero`.
@N-Dekker N-Dekker changed the title WIP: Test that Math::Absolute(-0.0) returns "plus zero" BUG: Math::Absolute(-0.0) should return "plus zero" (+0.0) Feb 17, 2026
@N-Dekker N-Dekker marked this pull request as ready for review February 17, 2026 14:32
@N-Dekker N-Dekker requested a review from dzenanz February 17, 2026 14:33
@hjmjohnson hjmjohnson merged commit a7bcfe6 into InsightSoftwareConsortium:main Feb 17, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Core Issues affecting the Core module type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants