This might be a silly question, but I really have an issue here with 0 and minus 0.
I am calculating a slope of a function and depending on the vector ( right or left ) it is 0 or -0.
Is it possible to do a if condition and find out if the slope is 0 or -0 ? Doing the below doesnt work.
if ( slope == 0.0f )
std::cout << "direction vector towards right";
else if ( slope == -0.0f )
std::cout << "direction vector towards left"
I deliberatly didnt put working source code, because I think it is irrelevant for the question. A simple answer for the above will help.
You're looking for std::signbit
. Both zeroes are equal to each other so your check doesn't work, but the signbit is different.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With