废话不多说,上代码
//编译环境:codeblocks+gcc
#include <stdio.h>
#include <stdint.h>
int Fun()
{
uint64_t y;
uint32_t x1, x2;
//y = 3000 * 24000000 / 1000;//常数默认作为32位数据,临时运算结果也是32位,溢出错误
//y = (uint64_t)3000 * (uint64_t)24000000 / 1000;//常数强制转换为64位,运算正确
y = 3000ULL * 24000000ULL / 1000ULL;//常数使用64位格式,运算正确
printf("0x%llX\n", y);//输出
x1 = (uint32_t)(y & 0xFFFFFFFF);
x2 = (uint32_t)(y >> 32);
printf("0x%X,0x%X \n", x1, x2);//输出结果
}
int main()
{
Fun();
}