https://www.zhihu.com/question/20159860/answer/71256667
The one's complement does not change the sign bit, and bitwise inversion changes each bit.
The computer stores it in complement, and the inversion of -1 is exactly 0. Take while(~scanf()) as an example