该程序输出的每一行都等于 2 ^ i
- 2,除了最后一行,等于 2 ^ 64 - 1。这是为什么呢?
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
int main(void) {
unsigned long long ONE = 1;
unsigned long long i;
for (i = 1; i <= 64; i++) {
printf("%"PRIu64"\n", (ONE << i) - 2);
}
return EXIT_SUCCESS;
}
输出:
0
2
6
14
30
62
126
254
510
1022
2046
...
4611686018427387902
9223372036854775806
18446744073709551615