Unsigned and signed comparison

后端 未结 5 1862
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-27 21:40

Here is very simple code,

#include 
using namespace std;
int main() {
    unsigned int u=10;
    int i;
    int count=0;
    for (i=-1;i<=         


        
5条回答
  •  有刺的猬
    2020-11-27 22:46

    On a system where an integer is stored in 4 bytes, I believe that the value of -1 equals the value of 2147483649 (1000 0000 0000 0000 0000 0000 0000 0001) - It's 1 with the MSB set to 1 to indicate it's negative.

提交回复
热议问题