int to unsigned int conversion

前端 未结 6 1541
长发绾君心
长发绾君心 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 21:01

    i=-62 . If you want to convert it to a unsigned representation. It would be 4294967234 for a 32 bit integer. A simple way would be to

    num=-62
    unsigned int n;
    n = num
    cout<

    4294967234

提交回复
热议问题