Xref: utzoo comp.arch:5619 comp.lang.c:11447 Path: utzoo!utgpu!water!watmath!clyde!att!ucbvax!decwrl!sun!gorodish!guy From: guy@gorodish.Sun.COM (Guy Harris) Newsgroups: comp.arch,comp.lang.c Subject: Re: Shifting question Message-ID: <60785@sun.uucp> Date: 21 Jul 88 06:26:40 GMT References: <705@bnr-rsc.UUCP> <440@softway.oz> Sender: news@sun.uucp Followup-To: comp.lang.c Lines: 22 > Contrary to the other two follow-ups I've seen (when will > people learn not to react without thinking), yes you do have a > valid complaint. The C language (both K+R and X3J11) > guarantees that X >> n is a logical shift, with 0 padding on > the left, when X is an unsigned quantity, as it is in this > case. It is only when X is not unsigned, that a right shift is > implementation dependant. I don't know which follow-ups *you* saw; none of the ones *I* saw said *anything* about smearing the sign bit. All the ones I saw pointed out, quite correctly, that he did *not* have a valid complaint, because the result of shifting a signed *or* unsigned 32-bit quantity right by 32 bits is undefined. It might arguably be more correct to say that complaining that his compiler wasn't "doing the right thing" according to some language specification wasn't valid. He could, I suppose, complain that the language specification should say what happens when you shift by more than the size of the LHS, in bytes, or that the hardware shouldn't take the shift count modulo 32, or that the compiler should "do the right thing" even though it's not required by the language specification; these might or might not be considered valid complaints depending on your point of view.