Path: utzoo!attcan!uunet!mcvax!ukc!warwick!cudcv From: cudcv@warwick.ac.uk (Rob McMahon) Newsgroups: comp.std.c Subject: Re: Shifting question Message-ID: <14@titania.warwick.ac.uk> Date: 25 Jul 88 21:23:22 GMT References: <705@bnr-rsc.UUCP> <11556@steinmetz.ge.com> <60290@sun.uucp> <19962@watmath.waterloo.edu> Reply-To: cudcv@warwick.ac.uk (Rob McMahon) Organization: Computing Services, Warwick University, UK Lines: 25 In article <19962@watmath.waterloo.edu> rbutterworth@watmath.waterloo.edu (Ray Butterworth) writes: |> In some article, someone whose name is lost in the mists of time writes: |> > action of doing: |> > x >>= 16; x>>= 16; |> > better be the same as: |> > x = x>>32; | |I can see why the Committee should NOT require that (for n>0) |"x >>= n;" be the same as "while (n--!=0) x>>=1;". | |Imagine a machine with 16 bit words and a logical right shift |instruction that only looks at the lowest 4 bits of the shift size. |... |No, I don't know of any such machine. Okay, to make this concrete, have a look at a Gould sometime. This hasn't actually got any `shift by variable' instructions, only shift by constant. A shift by variable is done by constructing an instruction in a register and then executing it. At the moment this requires AND-OR-EXECUTE, the people who are suggesting fixing the behaviour when `n' is < 0 or >= bits per word would force the compiler to add tests for n >= 32 or n < 0 to this. -- UUCP: ...!mcvax!ukc!warwick!cudcv PHONE: +44 203 523037 JANET: cudcv@uk.ac.warwick ARPA: cudcv@warwick.ac.uk Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England