Description
The relational and equality operators (<, <=, >, >=, !=, ==) can be used with scalar and vector built-in types and produce a scalar or vector signed integer result respectively.
The functions described in the Built-in Scalar and
Vector Relational Functions table can be used with built-in scalar or vector
types as arguments and return a scalar or vector integer result
[1].
The argument type gentype refers to the following built-in types: char,
charn, uchar, ucharn, short, shortn, ushort,
ushortn, int, intn, uint, uintn, long
[2], longn, ulong, ulongn, float,
floatn, double [3], and
doublen.
The argument type igentype refers to the built-in signed integer types
i.e. char, charn, short, shortn, int, intn, long
and longn.
The argument type ugentype refers to the built-in unsigned integer types
i.e. uchar, ucharn, ushort, ushortn, uint, uintn,
ulong and ulongn.
n is 2, 3, 4, 8, or 16.
The functions isequal, isnotequal, isgreater, isgreaterequal, isless, islessequal, islessgreater, isfinite, isinf, isnan, isnormal, isordered, isunordered and signbit described in the following table shall return a 0 if the specified relation is false and a 1 if the specified relation is true for scalar argument types. These functions shall return a 0 if the specified relation is false and a -1 (i.e. all bits set) if the specified relation is true for vector argument types.
The relational functions isequal, isgreater, isgreaterequal, isless, islessequal, and islessgreater always return 0 if either argument is not a number (NaN). isnotequal returns 1 if one or both arguments are not a number (NaN) and the argument type is a scalar and returns -1 if one or both arguments are not a number (NaN) and the argument type is a vector.
| Function | Description |
|---|---|
int isequal(float x, float y) int isequal(half x, half y) |
Returns the component-wise compare of x == y. |
int isnotequal(float x, float y) int isnotequal(half x, half y) |
Returns the component-wise compare of x != y. |
int isgreater(float x, float y) int isgreater(half x, half y) |
Returns the component-wise compare of x > y. |
int isgreaterequal(float x, float y) int isgreaterequal(half x, half y) |
Returns the component-wise compare of x >= y. |
int isless(float x, float y) int isless(half x, half y) |
Returns the component-wise compare of x < y. |
int islessequal(float x, float y) int islessequal(half x, half y) |
Returns the component-wise compare of x <= y. |
int islessgreater(float x, float y) int islessgreater(half x, half y) |
Returns the component-wise compare of (x < y) || (x > y) . |
int isfinite(float) int isfinite(half) |
Test for finite value. |
int isinf(float) int isinf(half) |
Test for infinity value (positive or negative). |
int isnan(float) int isnan(half) |
Test for a NaN. |
int isnormal(float) int isnormal(half) |
Test for a normal value. |
int isordered(float x, float y) int isordered(half x, half y) |
Test if arguments are ordered. isordered() takes arguments x and y, and returns the result isequal(x, x) && isequal(y, y). |
int isunordered(float x, float y) int isunordered(half x, half y) |
Test if arguments are unordered. isunordered() takes arguments x and y, returning non-zero if x or y is NaN, and zero otherwise. |
int signbit(float x) int signbit(half x) |
Test for sign bit. The scalar version of the function returns a 1 if the sign bit in x is set else returns 0. The vector version of the function returns the following for each component in x: -1 (i.e all bits set) if the sign bit in the float is set else returns 0. |
int any(igentype x) Scalar inputs to any are deprecated by OpenCL C version 3.0. |
Returns 1 if the most significant bit of x (for scalar inputs) or any component of x (for vector inputs) is set; otherwise returns 0. |
int all(igentype x) Scalar inputs to all are deprecated by OpenCL C version 3.0. |
Returns 1 if the most significant bit of x (for scalar inputs) or all components of x (for vector inputs) is set; otherwise returns 0. |
gentype bitselect(gentype a, gentype b, gentype c) |
Each bit of the result is the corresponding bit of a if the corresponding bit of c is 0. Otherwise it is the corresponding bit of b. |
gentype select(gentype a, gentype b, igentype c) |
For each component of a vector type, result[i] = if MSB of c[i] is set ? b[i] : a[i]. For a scalar type, result = c ? b : a. |
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.