且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在C或C ++中>> =的含义是什么?

更新时间:2022-10-15 20:01:24

The >>= symbol is the assignment form of right-shift, that is x >>= y; is short for x = x >> y; (unless overloaded to mean something different).

Right shifting by 1 is equivalent to divide by 2. That code looks like someone doesn't trust the compiler to do the most basic optimizations, and should be equivalent to:

for( int offset = blockDim.x; offset > 0; offset /= 2 ){ ... }

More information about bitwise operations here:

http://en.wikipedia.org/wiki/Binary_shift#Bit_shifts