如何证明1+1≠2

· · 休闲·娱乐

因为 int 的容量为 -2^{31} \sim -1 和 0 \sim 2^{31}-1。

所以 int 的总容量为 2^{32}(正负数、0)。

于是,只要我们让代码输出一个 int 类型的 2^{32},那么代码就会输出 0。

那我们可以开始证明了。

\because 0=2^{32} \therefore 0+1=1=2^{32}+1 \therefore 1+1=1+1+0=1+1+2^{32}

若 1+1=2,两边同时除以 2:

\therefore 1=3 \times 2^{31}+1

则 1=3 \times2^{31}+1=2^{31}+1,又 0=2^{32},故 0=2^{31},矛盾,故 1+1 \ne 2。