New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Negative zero does not pass compared to positive zero #1863
Comments
I don't consider this a bug.. This is intended C++ behaviour.. Floating points should therefore never be compared with ==, but with Have a look at the docs: https://github.com/catchorg/Catch2/blob/master/docs/assertions.md#floating-point-comparisons |
That is what I tried first, but gave the same result, I filed this bug after talking to Xarn on Discord.
|
OK, then this is the real issue, that the Approx doesn't catch it, but the plain == is thought to fail in this case.. |
The suspicious part of this is that it passes after the negative value is passed through |
ehm.. that actually makes sense to me..
why not multiply by |
🤦♂ I keep forgetting this, because @gregersn Does it still pass if you instead write As to the second, because if it multiplied by |
|
Yeah in that case the answer is "not actually a bug, sorry" 🤷♂ The lhs is some small value, that is however still non-zero. You need to set some "close-enough" value for your |
While the developers are free to argue this isn't a bug, there does seem to be a need for clarification in the docs. If try the test case
then, like the original reporter, I get a failure with
but if I use what the docs say are the default arguments and code up the test
then the test passes. If there isn't a bug here then I think there is at least a documentation issue. It seems like explicit vs. implicit margins give different results. |
from documentation.
|
Describe the bug
If a variable holds the floating point value of
-0.0f
/-0x1.777a5cp-24
, requiring it to be equal to0.0f
does not pass.Expected behavior
That
-0.0f == 0.0f
Reproduction steps
Steps to reproduce the bug.
float t = -0x1.777a5cp-24; REQUIRE(t == 0.0f);
Platform information:
Additional context
Doing
REQUIRE(abs(t) == 0.0f)
will pass.The text was updated successfully, but these errors were encountered: