A thread in the PIC/SX mailing list caused some discomfort about the workings of the shift right operation in different languages. Until now, I was convinced that the correct way to interpret that operation was in the 'logical' context, i.e., a clean bit operation, ignoring any significance of the MSb (=sign).
It seems it isn't that simple. It isn't even simple: some languages, like C, don't even specify how it will work: The C99 standard says it is 'implementation-dependent'. So C-compilers can differ in the way they do it.
Below are some texts I ran, using different languages/implementations.
|C||gcc 4.2.3||-8||-8||Test with 'int' type|
||2147483640||2147483640||Test with 'unsigned' type|
|Pascal||fpc 2.2.0||2147483640||-8||Test with 'integer' type|
||2147483640||2147483640||Test with 'longword' type|
|MySQL||mysql 5.0.20||9223372036854775800||-8||The large number is because of the default type|
|(c) John Coppens ON6JC/LW3HAZ||correo|