Description

The operators right-shift (>>), left-shift (link:https://www.khronos.org/registry/OpenCL/specs/2.2/html/OpenCL_C.html#) operate on all scalar and vector built-in types except the built-in scalar and vector float types. For built-in vector types[the operators are applied component-wise. For the right-shift (^]), left-shift (<<) operators, the rightmost operand must be a scalar if the first operand is a scalar, and the rightmost operand can be a vector or scalar if the first operand is a vector.

The result of E1 << E2 is E1 left-shifted by log2(N) least significant bits in E2 viewed as an unsigned integer value, where N is the number of bits used to represent the data type of E1 after integer promotion18, if E1 is a scalar, or the number of bits used to represent the type of E1 elements, if E1 is a vector. The vacated bits are filled with zeros.

[18] Integer promotion is described in section 6.3.1.1 of the C99 Specification.

The result of E1 >> E2 is E1 right-shifted by log2(N) least significant bits in E2 viewed as an unsigned integer value, where N is the number of bits used to represent the data type of E1 after integer promotion, if E1 is a scalar, or the number of bits used to represent the type of E1 elements, if E1 is a vector. If E1 has an unsigned type or if E1 has a signed type and a nonnegative value, the vacated bits are filled with zeros. If E1 has a signed type and a negative value, the vacated bits are filled with ones.