Problem is that in the operation: a = a >> 1; 'a' is promoted to an unsigned integer for normal operations before the final result being downcasted back. So we get the following sequence. a => -1 cast(uint) => 4294967295 a >> 1 => 2147483647 cast(short) => -1