int to unsigned int conversion

前端 未结 6 1565
长发绾君心
长发绾君心 2020-11-29 20:33

I\'m just amazed to know that I can\'t convert signed to unsigned int by casting!

int i = -62;
unsigned int j = (unsigned int)i;

I thought

6条回答
  •  孤街浪徒
    2020-11-29 20:56

    with a little help of math

    #include 
    int main(){
      int a = -1;
      unsigned int b;
      b = abs(a);
    }
    

提交回复
热议问题