What does ~0 do?

前端 未结 4 1988
有刺的猬
有刺的猬 2020-12-11 08:13

Does ~0 mean its flipping 000000000 to 1111111111?

printf(\"Check: %i\", ~0);

The printf results to -1, which is why I am confused. <

4条回答
  •  我在风中等你
    2020-12-11 08:46

    Does ~0 mean its flipping 000000000 to 1111111111?

    Yes, it does.

    Does -1 essentially mean the same thing as 11111111111111111 bits?

    In 2s complement representation, it does.

提交回复
热议问题