Is it safe to assume that the condition (int)(i * 1.0f) == i is true for any integer i?
No it is absolutely wrong for all the integers because of the type cast. check code.
#include
int main()
{
int i = 0;
for (; i < 2147483647; ++i) {
if ((int)(i * 1.0f) != i) {
printf("not equal\n");
break;
}
}
printf("out of the loop\n");
getchar();
return 0;
}
This code assumes that you take 32 bit integer