過去ログ
No.592.オーバーフローの検知
符号付きなら、 c = a + b; if (((c^a) & (c^b)) < 0) puts("overflow"); 符号無しなら、 c = a + b; if (c < a) puts("overflow");