我尝试了以下方法,似乎“测试”导致错误值。2500*2500*2500 == 15625000000,为什么下面的操作会导致不同的结果?
unsigned long long int test = 2500*2500*2500;
fprintf(stderr, "*************** test = %lld, %llu\n", test, test);
unsigned long long int test2 = 15625000000;
fprintf(stderr, "*************** test2 = %lld, %llu\n", test2, test2);
结果:
*************** test = -1554869184, 18446744072154682432
*************** test2 = 15625000000, 15625000000