- a, b, c 均是 32-bit 的整數 (signed integer)
- a = 2147483647
- b = -2147483648
- c = b - a = 1
- 十進位表示:
c(1) = b(-2147483648) - a(2147483647) - 十六進位表示:
c(0x00000001) = b(0x80000000) - a(0x7FFFFFFF)
以下是對映的 C 程式:
void main(void)
{
int32_t a;
int32_t b;
int32_t c;
a = 0x7FFFFFFF;
printf ("a(%d)\n", a);
b = a+1;
printf ("b(%d)\n", b);
c = b - a;
printf ("c(%d) = b(%d) - a(%d)\n", c, b, a);
printf ("c(0x%08X) = b(0x%08X) - a(0x%08X)\n", c, b, a);
}
3 則留言:
I really love your Blog, the verification stuffs are really good!
Hi YK,
我曾經提供過一些更新給 truss 的作者,但也未見他們將新版的程式碼釋放出來。我後來將 truss 改成適合我使用的樣子,一直用到現在。你試過 teal/truss 了嗎?
-ysli
張貼留言