Shifting question
Alan Fargusson
alanf%smile at Sun.COM
Thu Jul 21 04:43:35 AEST 1988
In article <1818 at spar.SPAR.SLB.COM>, hunt at 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 at sun.com ..!sun!alanf
More information about the Comp.lang.c
mailing list