can anyone tell me how this is possible ?
the output would beCode:
#define LESS(x,y) ((x)-(y)<0)
int main()
{
unsigned int first_t =0;
unsigned int secont_t=0;
int j=0;
first_t=~first_t ; // to make it all ones
first_t=first_t - 1000; // now first_t is MAX_INT - 1000
second_t = first_t + 20 ; // now first_t < second_t
//first check
if (LESS(first_t, second_t))
printf(" first is less \n");
for (;j<5000;j++)
first_t++;
// at this point, first_t will have wrapped around ,
// so the value would be 3999 ( or 4000)
// second_t will have very high value 429496.......
// second will have 3999, since it wrapped around , the actual
// value should be second_t+(5000-20)
if (LESS(first_t,second_t))
printf("1.... first is still less ....\n");
else
printf(".1..... second is more \n");
if (second_t > first_t)
printf(" 2......first is less \n");
else
printf(".2.......second is more \n");
return 0;
}
1 second is more
2 firsrt is less
why is this ??
}