I am wondering if things like this :
int a = ...;
long b = ...;
if (a < b)
doSomethings();
always works (excepted for unsigned)
In this condition
if (a < b)
an object of type int
is always converted to the type long
provided that one of the operands has type long
because type long
has higher rank than type int
.
As for other types then according to the C Standard (6.5.8 Relational operators)
3 If both of the operands have arithmetic type, the usual arithmetic conversions are performed.
It means that after the integer promotion an operand with a lower rank is converted to the type of the other operand.