'How to make JUnit ignore difference between 0.0f and -0.0f [duplicate]

I am trying to write a unit test for the inverse of a matrix.

At some places where I have 0.0f, and the inversed cell has -0.0f, it gives an error that those cells are not equal.

Is there a way to ignore that error?



Solution 1:[1]

Fixed by correcting the equals() function to ignore 0.0f in the current matrix and -0.0f in the one which is being compared or vice versa, so it will skip over that difference.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 David Petriashvili