小编Shi*_*han的帖子

long long Integer乘法中的错误是什么?

 #include<stdio.h>
 int main()
 {
     long long int t=8*9*100000000;// 8 zeros
     printf("%lld\n",t);
     return 0;
 }
Run Code Online (Sandbox Code Playgroud)

给出结果: -1389934592


请回复

 #include<stdio.h>
 int main()
 {
     long long int t=8*9*1000000000; //9zeros
     printf("%lld\n",t);
     return 0;
 }
Run Code Online (Sandbox Code Playgroud)

给出结果: -1014444032


所有其他乘法给出了正确的结果,即

 #include<stdio.h>
 int main()
 {
     long long int t=8*9*10000000000; //10zeros or greater or zeros <=6
     printf("%lld\n",t);
     return 0;
 }
Run Code Online (Sandbox Code Playgroud)

给出结果: 720000000000


c memory int long-integer

4
推荐指数
1
解决办法
728
查看次数

标签 统计

c ×1

int ×1

long-integer ×1

memory ×1