What are the general rules for comparing different data types in C?

Viewed 16142

Lets say I have the following scenarios:

int i = 10;
short s = 5;

if (s == i){
   do stuff...
} else if (s < i) {
  do stuff...
}

When C does the comparison does it convert the smaller data type, in this case short to int or does it convert the data type on the right to the data type on the left? In this case int to short?

4 Answers
Related