I', trying this simple code. It shows the first 10 integers that can not be represented in float:
int main(){
int i, cont=0;
float f;
double di, df;
for(i=10000000, f=i; i<INT_MAX; i++, f=i, df=f, di=((float)i)){
if(i!=f){
printf("i=%d f=%.2f df=%.2lf di=%.2lf\n", i, f, df, di);
if(cont++==10) return 0;
}
}
return 1;
}
di is a double variable, but I set it to (float)i, so it should be equal to df, but it is not.
For example, the number 16777217 is represented as 16777216 by f and df, but di is still 16777217, ignoring the (float) casting.
How is this possible?
**I am using this: gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3