K & R indicates that if either operand is int , then the other operand will be converted to int . Of course, this is only after all other rules are observed (for example, long double , float , unsigned int , etc.).
By this logic, char will be converted to int if the other operand was int . But what if the highest integer type in the operation is short ?
Now, obviously, I donβt need to explicitly convert char to a larger integer, but I really wonder if ANSI-C handles the implicit conversion between char and short under the hood? K & R says nothing about this.
Let's say I have the following lines of code:
char x = 'x'; short y = 42; short z = x + y;
Will x converted to short ? Or will there be no conversion at all?
Just to make it clear: I am not asking if I need to convert from char to short or how. I just want to know what happens with respect to implicit type conversions.
source share