int main() { unsigned int ui = 2147483647; if (ui + 1 > 0) printf("ui + 1 > 0\n"); if (ui + 1 < -1) printf("ui + 1 < -1\n"); return 0; }
C:\SVN\book\C>a.exe ui + 1 > 0 ui + 1 < -1
有號數 遇到 unsigned 就會變成無號數... 所以-1 變成了0xFFFFFFFF
有號數 遇到 unsigned 就會變成無號數...
回覆刪除所以-1 變成了0xFFFFFFFF