unsigned int and signed char comparison

后端 未结 4 853
死守一世寂寞
死守一世寂寞 2020-11-27 07:36

I am trying to compare an unsigned int with a signed char like this:

int main(){
  unsigned int x = 9;
  signed char y = -1;
  x < y ? printf(\"s\") : pri         


        
4条回答
  •  囚心锁ツ
    2020-11-27 08:14

    My guess is y is promoted to unsigned int which becomes a big value (due to wrapping). Hence the condition is satisfied.

提交回复
热议问题