I have a problem where some additional bits are being set in a number:
void print2_helper(int x) {
int isodd = x%2 != 0;
x /= 2;
if (x)
print2_helper(x);
putchar('0' + isodd);
}
printf("-7 << 16: ");
print2_helper((-7 << 16));
printf("\n(-7 << 16) | 75: ");
print2_helper((-7 << 16) | 75);
puts("\n");
Output:
-7 << 16: 1110000000000000000
(-7 << 16) | 75: 1101111111110110101
Why doing simple |75 produces such a weird number full of ones?