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 functions35 described in the following table can be used with built-in scalar or vector types as arguments and return a scalar or vector integer result. The argument type gentype refers to the following built-in types: char, charn, uchar, ucharn, short, shortn, ushort, ushortn, int, intn, uint, uintn, long, longn, ulong, ulongn, float, floatn, double, 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.

[35] If an implementation extends this specification to support IEEE-754 flags or exceptions, then all builtin functions defined in the following table shall proceed without raising the invalid floating-point exception when one or more of the operands are NaNs.

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) intn isequal(floatn x, floatn y) int isequal(double x, double y) longn isequal(doublen x, doublen y) Returns the component-wise compare of x == y. int isnotequal(float x, float y) intn isnotequal(floatn x, floatn y) int isnotequal(double x, double y) longn isnotequal(doublen x, doublen y) Returns the component-wise compare of x != y. int isgreater(float x, float y) intn isgreater(floatn x, floatn y) int isgreater(double x, double y) longn isgreater(doublen x, doublen y) Returns the component-wise compare of x > y. int isgreaterequal(float x, float y) intn isgreaterequal(floatn x, floatn y) int isgreaterequal(double x, double y) longn isgreaterequal(doublen x, doublen y) Returns the component-wise compare of x >= y. int isless(float x, float y) intn isless(floatn x, floatn y) int isless(double x, double y) longn isless(doublen x, doublen y) Returns the component-wise compare of x < y. int islessequal(float x, float y) intn islessequal(floatn x, floatn y) int islessequal(double x, double y) longn islessequal(doublen x, doublen y) Returns the component-wise compare of x <= y. int islessgreater(float x, float y) intn islessgreater(floatn x, floatn y) int islessgreater(double x, double y) longn islessgreater(doublen x, doublen y) Returns the component-wise compare of (x < y) || (x > y) . int isfinite(float) intn isfinite(floatn) int isfinite(double) longn isfinite(doublen) Test for finite value. int isinf(float) intn isinf(floatn) int isinf(double) longn isinf(doublen) Test for infinity value (positive or negative). int isnan(float) intn isnan(floatn) int isnan(double) longn isnan(doublen) Test for a NaN. int isnormal(float) intn isnormal(floatn) int isnormal(double) longn isnormal(doublen) Test for a normal value. int isordered(float x, float y) intn isordered(floatn x, floatn y) int isordered(double x, double y) longn isordered(doublen x, doublen 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) intn isunordered(floatn x, floatn y) int isunordered(double x, double y) longn isunordered(doublen x, doublen 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) intn signbit(floatn) int signbit(double) longn signbit(doublen) Test for sign bit. The scalar version of the function returns a 1 if the sign bit in the float is set else returns 0. The vector version of the function returns the following for each component in floatn: -1 (i.e all bits set) if the sign bit in the float is set else returns 0. int any(igentype x) Returns 1 if the most significant bit in any component of x is set; otherwise returns 0. int all(igentype x) Returns 1 if the most significant bit in all components of x 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) gentype select(gentype a, gentype b, ugentype 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. igentype and ugentype must have the same number of elements and bits as gentype36.

[36] The above definition means that the behavior of select and the ternary operator for vector and scalar types is dependent on different interpretations of the bit pattern of c.