using System;
class OverflowCheck
{
public static bool AddingWillOverflow(int x, int y) {
return ((x > 0) && (y > int.MaxValue - x)) || ((x < 0) && (y < int.MinValue - x));
}
static void Main()
{
int x = 39839299, y = 1472783642;
Console.WriteLine(AddingWillOverflow(x, y) ? "true" : "false");
x = 1338839299; y = 1872783642;
Console.WriteLine(AddingWillOverflow(x, y) ? "true" : "false");
}
}
/*
run:
false
true
*/