1/0 is not equal to 2/0, they are both errors but not the same.
#include <stdio.h>
int main()
{
float a = 1. / 0;
float b = 2. / 0;
printf("%f == %f ? %d\n", a, b, a == b);
return 0;
}
will print: inf == inf ? 1
Moreover: #include <stdio.h>
int main()
{
float a = 0. / 0;
float b = a;
printf("%f == %f ? %d\n", a, b, a == b);
return 0;
}
nan == nan ? 0
So this is certainly surprising without knowing quite a bit already about floats, because it means = is not only not transitive but even not reflexive.What's equal to infinity is the limit of 1 / x as x approaches 0, and that's only from the positive side. From the negative side, it's -infinity.