- TEST_FUN(
- test_1a,
- "unsigned int minus test"
- )
- {
- unsigned i=3;
- unsigned j=5;
- i = i - j;
- printf("i = 3, j = 5, i - j = %ud/n", i);
- }
- --------------
- test_1a测试结果:
- --------------
- Test : test_1a
Function : unsigned int minus test
--------------
i = 3, j = 5, i - j = 4294967294d
C诡异bug测试连载_2 (unsigned int 减法的恶梦)
本文展示了一个简单的无符号整数减法测试案例。通过一个具体的例子:将无符号整数3减去5,展示了在计算机中如何处理这种运算,并且得到了预期之外的结果4294967294,解释了溢出现象。

被折叠的 条评论
为什么被折叠?



