interesting integer type comparison problem
Hi, I have curious question when reviewing C in terms of integer type comparison.
What happens when
int a;
long int b;
double c;
...
if (a>b) { <----?
.....
} else
if (a<c) { <----?
...
}
I know conversion rules for integer and so on. But I think they only apply for arithmetic operation. I assume > < operator will be different. But can't imagine the details.. maybe sth like
1> variable a hoist to long int to match with b's type
2> compare a and b by substracting (at assembly level cmp)
The underlying question is that will truncation or undefined behavior happen..
Your thoughts are highly appreciated.
|