C语言溢出判断

看到一段python原码中对c加法溢出的判断。暂记下来

long a = xxx;
long b = xxx;
long sum = a + b;
if ((a^sum)<0 && (a^sum )<0)
{
  //overflow detected
}
...

点赞