Would making plain int 64-bit break a lot of reasonable code?

后端 未结 8 2139
独厮守ぢ
独厮守ぢ 2021-02-19 03:12

Until recently, I\'d considered the decision by most systems implementors/vendors to keep plain int 32-bit even on 64-bit machines a sort of expedient wart. With mo

8条回答
  •  旧时难觅i
    2021-02-19 03:48

    While I don't personally write code like this, I'll bet that it's out there in more than one place... and of course it'll break if you change the size of int.

    int i, x = getInput();
    for (i = 0; i < 32; i++)
    {
        if (x & (1 << i))
        {
            //Do something
        }
    }
    

提交回复
热议问题