I have this question:
We claim that it is unsafe to use equality testing with floating point numbers because the arithmetic operations introduce rounding errors which mean that two numbers which ought to be equal are not.
For this program, you should pick a number N, and write a program to show for which of the integers x between 1 and 1000 the equality (x+1)/N = (x/N) + (1/N) fails
#include <stdio.h>
int main () {
int x;
float N = 50;
for (x=0; x<1001; x++) {
if ((x+1)/N != (x/N) + (1/N))
{
printf("%i\n",x);
}
}
}
Is this correct?
Thanks.