--- In [email protected], "John Matthews" <jm5...@...> wrote: > > --- In [email protected], "mikejd42" <mikejd42@> wrote: > > > > --- In [email protected], "John Matthews" <jm5678@> wrote: > > > > > > newPixel = (pixel1 + pixel2) / 2; > > > > > instead of the "/2" use " >> 1" its faster with less overhead. > > The compiler will generate code that effectively does >>1 to implement the /2 > (if it doesn't then time to change compilers). So I would argue that it's > better to write it as /2 because logically that's what you want to do. >
Logically you want to shift right one. I believe it is better to think optimally and code that way than to let the compiler do it. Far too many programmers are not trained to optimize and scrutinize their code. When you think how can I best write this to be a good steward of the machine resources it becomes second nature to write a /2 as shift right one and *2 as shift left one.
