c/c++的一些验证

  1. 内置整数类型(如int、unsinged int、char、short)变量赋值时,如果右侧数值实际位宽大于左侧变量位宽,存在高位截断现象:
int a = 257;
unsigned char b = a; // 实际b的值为1,高位被直接截断

float c = 3.7e38; // 实际c的值为inf,超出32位浮点数上限
posted @ 2025-04-28 14:19  VoidSalts  阅读(4)  评论(0)    收藏  举报