Path: utzoo!attcan!uunet!husc6!mailrus!ames!oliveb!sun!smile!alanf From: alanf%smile@Sun.COM (Alan Fargusson) Newsgroups: comp.lang.c Subject: Re: Shifting question Message-ID: <60670@sun.uucp> Date: 20 Jul 88 18:43:35 GMT References: <705@bnr-rsc.UUCP> <11556@steinmetz.ge.com> <60290@sun.uucp> <1818@spar.SPAR.SLB.COM> Sender: news@sun.uucp Lines: 18 In article <1818@spar.SPAR.SLB.COM>, hunt@spar.SPAR.SLB.COM (Neil Hunt) writes: > rshift = count > 0 ? count : 0; > lshift = count < 0 ? -count : 0; > > for(j = 0; j < image->rows; j++) > for(i = 0; i < image->cols; i++) > image->pixels[i][j] = > ((image->pixels[i][j] >> rshift) << lshift); > > We are talking factors of two in execution time for these functions. > What a pain !! What is your solution? Since most (I think all) hardware does not handle shift count less then zero the compiler would have to generate the same code that it generates for your example above. - - - - - - - - - - - - - - - - - - - - - Alan Fargusson Sun Microsystems alanf@sun.com ..!sun!alanf