How do unsigned integers work

前端 未结 3 896
情书的邮戳
情书的邮戳 2021-01-13 21:13

As the title suggests, I am curious about how an unsigned int (or things like NSUInteger, u_int_blah, but I assume these are all

3条回答
  •  -上瘾入骨i
    2021-01-13 21:49

    When you assign a negative number

    unsigned int = -1;
    

    The number you got will be 4294967295, or 4^8 -1

    because the size of integer is 4bytes, or 4^8 = 4294967296

    The integer will wrap around this number if it is negative

提交回复
热议问题