meaning of a=b>>1

I am cheking a function writed in a library dor digital image processing by other programmer,
1
2
3
4
5
6
7
bool convolve2DSeparable(unsigned char* in, unsigned char* out, int dataSizeX, int dataSizeY, 
                         float* kernelX, int kSizeX, float* kernelY, int kSizeY)
{
//some input checking  code

            // find center position of kernel (half of kernel size)
    kCenter = kSizeX >> 1;                          // center index of kernel  

I do not understand what kCenter = kSizeX >> 1; means, the thing is KsizeX I know is an integer so I would expect more somenthing like kCenter = ceil(kSizeX/2); instead it is used >> which the only usage I know is as cin. Can somebody explaining me what I am missing
Last edited on
1
2
3
4
// it is reading the >>  as a math operation in this case which is shift right 1 bit.
KCenter = kSize >> 1;

// it will not equal what you were trying to achieve. 
It's the bitshift operator. It takes the binary representation of the variable and shifts the bits left (<<) or right (>>) the number of times specified.

http://cplusplus.com/doc/tutorial/operators/
Azagaros wrote:
it will not equal what you were trying to achieve.

Are you sure? A quick test with some fairly small values looks like it does. Well approximately at least as its basically integer division.
it is a division by 2, which I forgot.
Topic archived. No new replies allowed.