I have two floating point number a
and b
. I want to check if they have different signs. The easy way is to see
bool b = a * b < 0;
But the two numbers are very small and a * b might be underflow. Any other simple way to check it?
Anyone thinking it is a duplicate question please give me an answer that exactly matches the condition a * b < 0
. Note here the sign of 0 is undefined in my question.