Assume you're given this excerpt of code:
Example 1:
printf("Enter two real numbers: ");
scanf("%f %f", &a, &b);
if (a == b) //do something
My question is: Is it necessary to use some "safety measures" when comparing floats directly taken from keyboard?
For instance if I'm given the similar code:
Example 2:
printf("Enter two real numbers: ");
scanf("%f %f", &a, &b);
float x = a / b + 2 * a / 3;
float y = b / a + 3 * a / 2;
if (x == y) //do something
I know I should be using:
fabs(x - y) < RefValue
for if's condition just to avoid potential occurence of false even if the result should be true. But do I have to do so in Example 1, too?