int a = 181; // in binary 0000 0000 0000 0000 0000 0000 1011 0101 a = a << 5; // a is now 0000 0000 0000 0000 0001 0110 1010 0000 = 5792 // everything has moved 5 bits to the left int b = 5792; // in binary 0000 0000 0000 0000 0001 0110 1010 0000 b = b >> 3; // b is now 0000 0000 0000 0000 0000 0010 1101 0100 = 724 // everything has moved 3 bits to the right int c = -181; // in binary 1111 1111 1111 1111 1111 1111 0100 1011 c = c << 5; // c is now 1111 1111 1111 1111 1110 1001 0110 0000 = -5792 // everything has moved 5 bits to the left int d = -5792; // in binary 1111 1111 1111 1111 1110 1001 0110 0000 d = d >> 3; // d is now 1111 1111 1111 1111 1111 1101 0010 1100 = -724 // all 5 to the left again. Ordinary int: sign bit preserved unsigned int e = d; // still 1111 1111 1111 1111 1111 1101 0010 1100 = 4294966572 e = e >> 3; // e is now 0001 1111 1111 1111 1111 1111 1010 0101 = 536870821 // unsigned int: no sign bit to preserve so zeros entered int f = 459910373; // in binary 0001 1011 0110 1001 1010 1100 1110 0101 int g = 902261465; // in binary 0011 0101 1100 0111 0110 1010 1101 1001 int h = f & g; // h is 0001 0001 0100 0001 0010 1000 1100 0001 = 289482945 // a 1 in the result only when both operands have a 1 // f is still 0001 1011 0110 1001 1010 1100 1110 0101 // g is still 0011 0101 1100 0111 0110 1010 1101 1001 int i = f | g; // i is 0011 1111 1110 1111 1110 1110 1111 1101 = 1072688893 // a 1 in the result when there is a 1 in any or both operands // f is still 0001 1011 0110 1001 1010 1100 1110 0101 // g is still 0011 0101 1100 0111 0110 1010 1101 1001 int j = f ^ g; // j is 0010 1110 1010 1110 1100 0110 0011 1100 = 783205948 // a 1 in the result when the bits in the operands are different // f is still 0001 1011 0110 1001 1010 1100 1110 0101 int k = ~ f; // k is 1110 0100 1001 0110 0101 0011 0001 1010 = -459910374 // every digit is inverted, 0 -> 1 and 1 -> 0 // f is still 0001 1011 0110 1001 1010 1100 1110 0101 unsigned int l = ~ f; // l is 1110 0100 1001 0110 0101 0011 0001 1010 = 3835056922 // the same bits, but getting a different interpretation int m = -74; // m is 1111 1111 1111 1111 1111 1111 1011 0110 unsigned int n = m; // n is 1111 1111 1111 1111 1111 1111 1011 0110 = 4294967222 // the same bits, but getting a different interpretation