gpt4 book ai didi

c - 当我按位移位 1 << 45 时,怎么会得到一个大整数

转载 作者:太空宇宙 更新时间:2023-11-04 00:15:34 25 4
gpt4 key购买 nike

为什么我得到这么大的整数?

int ans = 1 << 45;
printf("Check: %d", ans);
return 0;

查询:1858443624

最佳答案

这是 C 中的未定义行为。任何事情都可能发生,包括处理器异常或程序其他部分的不可预测的更改(这可能是积极的编译器优化的副作用)。

6.5.7/3 [...] If the value of the right operand is negative or is greater than or equal to the width of the promoted left operand, the behavior is undefined.

Source

关于c - 当我按位移位 1 << 45 时,怎么会得到一个大整数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12221819/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com