Console.WriteLine(7 << 4);
Console.WriteLine(7 >> (32 - 4));
For some reason the second method returns 0 instead of 112. But they both should be equal to one another, they both should return 112.
UPDATE:
It’s known that (x << n) == (x >> (32 - n)).
Your ideas?
Don’t really understand what you expect to see here:
7 << 4is shifting left (like multiplication)7 * (2 ^ 4) = 7 * 16 = 112on another hand
7 >> (32 - 4)is shifting right (like division)7/(2^28), that converted to integer value leads to0.The question is why
Console.WriteLinepeaks integer overload: is cause you act on integer values so expected byCLRresult isint.So result is correct.