The relational operators16 greater than (>), less than (<), greater than or equal (>=), and less than or equal (<=) operate on scalar and vector types. All relational operators result in an integer type. After operand type conversion, the following cases are valid:
 To test whether any or all elements in the result of a vector relational operator test true, for example to use in the context in an if ( ) statement, please see the any and all builtins.
The two operands are scalars. In this case, the operation is applied, resulting in an
One operand is a scalar, and the other is a vector. In this case, 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 two operands are vectors of the same type. In this case, the operation is done component-wise resulting in the same size vector.
All other cases of implicit conversions are illegal.
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
ucharn return a
charn result; vector source operands of type
ushortn return a
shortn result; vector source operands of type
floatn return an
intn result; vector
source operands of type
doublen return a
For scalar types, the relational operators shall return 0 if the specified
relation is false and 1 if the specified relation is true.
For vector types, the relational operators shall return 0 if the specified
relation is false and -1 (i.e. all bits set) if the specified relation is
The relational operators always return 0 if either argument is not a number
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.
Copyright (c) 2014-2020 Khronos Group. This work is licensed under a Creative Commons Attribution 4.0 International License.