📜  数字溢出 - 无论代码示例

📅  最后修改于: 2022-03-11 14:57:02.329000             🧑  作者: Mango

代码示例1
int x = 2147483647;    // maximum value that can be represented as an int
int y = x + 1;         // operation that causes overflow, since the result
                       // 2147483648 cannot be represented as an int
System.out.println(y); // prints -2147483648 instead of 2147483648
                       // (which is the number we would expect)