arithmetic overflow

来源:互联网 发布:弹道计算软件中文版 编辑:程序博客网 时间:2024/05/16 19:34

今天在codility上做练习,发现了自己经常忽视的一个算数溢出的问题,mark一下。

int i = 2;int j = 2147483647;long long k = i + j; // arithmetic overflow!// should declare i or j as 'long long' too; otherwise, i+j is of type 'int' before assigned to k.


0 0