Description
The arithmetic operators add (+), subtract (), multiply (*) and divide (/) operate on builtin integer and floatingpoint scalar, and vector data types. The arithmetic operator remainder (%) operates on builtin integer scalar and integer vector data types. All arithmetic operators return result of the same builtin type (integer or floatingpoint) as the type of the operands, after operand type conversion. After conversion, the following cases are valid:

The two operands are scalars. In this case, the operation is applied, resulting in a scalar.

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 componentwise resulting in the same size vector.

The two operands are vectors of the same type. In this case, the operation is done componentwise resulting in the same size vector.
All other cases of implicit conversions are illegal. Division on integer types which results in a value that lies outside of the range bounded by the maximum and minimum representable values of the integer type will not cause an exception but will result in an unspecified value. A divide by zero with integer types does not cause an exception but will result in an unspecified value. Division by zero for floatingpoint types will result in ±∞ or NaN as prescribed by the IEEE754 standard. Use the builtin functions dot and cross to get, respectively, the vector dot product and the vector cross product.
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.