今天在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.
今天在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.