Bit inversion problem

I have a problem with bit inversion operator( ~ )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>

using namespace std;

int main()
{
	int x, y;
	x = 12;
	y = ~x;
	
	cout << y;
	
	return 0;
}

As you see, value of x is equal to 12( 1100 ).
So I think the value of y is equal to 3( 0011 ).
But when I try to compile this program, the value of y is -13.
What is the problem?
An int is signed and contains more bytes so you won't get that result.
Even on an unsigned char the result would be difference as usually bytes have 8 bits
00001100
11110011 = 243
Ok, thank you very much.
Topic archived. No new replies allowed.