...
int a = x;
int b = 0;
for(int i= 29;i>=0;i--)
{
if((x & (1 << i)) > 0)
{
continue;
}
if((2*x - a - b) >= (2 << i))
{
// bug(a,b);
a += (1 << i);
b += (1 << i);
}
}
When I am making the start from i= 30 or more, it makes a negative. Why?
Note: I defined int as long long. Still, It's doing the same.
Can anyone please explain?