1999.02.25 13:57 "Re: Pb with LZW", by Peter Nielsen

1999.02.25 15:22 "Re: Pb with LZW", by Tom Lane

According to the C/C++ standard the result should be zero (0) if all bits are shifted out.

Can you cite chapter and verse on that? My book about Standard C (Plauger & Brodie) says that the result of shifting an N-bit value is defined by the standard only for shift counts 0 <= C < N.

I believe the C committee wrote that because they are aware of machines where the hardware takes the shift count modulo N.

Microsoft, on the other hand has redefined the standard and the manual says that the result is "undefined" if all bits are shifted out.

Portable code probably should avoid assuming that a full-width shift gives a predictable result. It will break on more platforms than just Microsoft.

                        regards, tom lane