32位数值移位后存入64位数值,注意类型转换,不然会溢出。
-
#include <stdio.h>
-
-
int main(int argc, char **argv)
-
{
-
long long t = 1;
-
for (int i = t; i <63; ++i)
-
{
-
t = (t<<1);
-
printf("%d %lld\n", i, t);
-
}
-
for (int i = 0; i < 63; ++i)
-
{
-
t = ((long long)1 << i);
-
printf("%d %lld\n", i, t);
-
}
-
-
return 0;
-
}
阅读(349) | 评论(0) | 转发(0) |