Description
The logical operators and (&&) and or (||) operate on all scalar and vector built-in types. For scalar built-in types only, and (&&) will only evaluate the right hand operand if the left hand operand compares unequal to 0. For scalar built-in types only, or (||) will only evaluate the right hand operand if the left hand operand compares equal to 0. For built-in vector types, both operands are evaluated and the operators are applied component-wise. If one operand is a scalar and the other is a vector, the scalar may be subject to the usual arithmetic conversion to the element type used by the vector operand. The scalar type is then widened to a vector that has the same number of components as the vector operand. The operation is done component-wise resulting in the same size vector.
The logical operator exclusive or (^^) is reserved.
The result is a scalar signed integer of type int if the source operands
are scalar and a vector signed integer type of the same size as the source
operands if the source operands are vector types.
Vector source operands of type charn and ucharn return a
charn result; vector source operands of type
_halfn [1],
shortn and
ushortn return a shortn result; vector source operands of type
intn, uintn and floatn return an intn result; vector
source operands of type longn, ulongn and doublen return a
longn result.
For scalar types, the logical operators shall return 0 if the result of the operation is false and return 1 if the result is true. For vector types, the logical operators shall return 0 if the result of the operation is false and return -1 (i.e. all bits set) if the result is true.
Document Notes
For more information, see the OpenCL C Specification
This page is extracted from the OpenCL C Specification. Fixes and changes should be made to the Specification, not directly.