I have two
double a, b;
I know that the following is true
-1 <= a/b <= 1
however b can be arbitrarily small. When I do this naively and just compute the value
a/b
the condition specified above does not hold in some cases and I get values like much greater than 1 in absolute value (like 13 or 14.)
How can I ensure that when I divide by b, I get a value such that the condition mentioned above can be enforced. In the case where I can not guarantee this I am happy to set the computed value a/b to 0.