convert_<dest type name>(srctype)
destType convert_destType<_sat><_roundingMode> (sourceType)
destTypen convert_destTypen <_sat><_roundingMode> (sourceTypen )

Explicit conversions may be performed using the convert_<dest type name>(srctype)
suite of functions. These provide a full set of type conversions between supported types (see
Scalar Data Types)
except for the following types:
half, size_t, ptrdiff_t, intptr_t, uintptr_t, and void. The number of elements in the source and destination vectors must match.
Explicit conversions from a type to the same type has no effect on the type or value of an expression.
The behavior of the conversion may be modified by one or two optional modifiers that specify saturation for outofrange inputs and rounding behavior.
The full form of the scalar convert function is:
destType convert_destType<_sat><_roundingMode>(sourceType)
The full form of the vector convert function is:
destType
n
convert_destTypen
<_sat><_roundingMode>(sourceTypen
)
The operand and result type may be the same type and must have the same number of elements. Conversions are available for the following scalar types and builtin vector types derived therefrom: bool, char, uchar, short, ushort, int, uint, long, ulong, and float.
Conversions to and from floatingpoint type shall conform to IEEE754 rounding rules. Conversions involving a floatingpoint or integer source operand or destination type may have an optional rounding mode modifier. These are described in the table below:
Modifier  Rounding Mode Description 


Round to nearest even 

Round towards zero 

Round toward positive infinity 

Round toward negative infinity 
no modifier specified 
Use the default rounding mode for this destination type, 
By default, conversions to integer type use the _rtz
(round toward zero) rounding mode and conversions to floatingpoint type use the current rounding mode. The only default floatingpoint rounding mode supported is round to nearest even i.e the current rounding mode will be _rte
for floatingpoint types.
When the conversion operand is either greater than the greatest representable destination value or less than the least representable destination value, it is said to be outofrange. When converting between integer types, the resulting value for outofrange inputs will be equal to the set of least significant bits in the source operand element that fit in the corresponding destination element. When converting from a floatingpoint type to integer type, the behavior is implementation defined.
Conversions to integer type may opt to convert using the optional saturated mode by appending
the _sat
modifier to the conversion function name. When in saturated mode, values that are
outside the representable range shall clamp to the nearest representable value in the destination
format. (NaN should be converted to 0).
Conversions to floatingpoint type shall conform to IEEE754 rounding rules. The _sat modifier may not be used for conversions to floatingpoint formats.
For conversions to floatingpoint format, when a finite source value exceeds the maximum representable finite floatingpoint destination value, the rounding mode will affect whether the result is the maximum finite floatingpoint value or infinity of same sign as the source value, per IEEE754 rules for rounding.
short4 s; // ve values clamped to 0 ushort4 u = convert_ushort4_sat( s ); // values > CHAR_MAX converted to CHAR_MAX // values < CHAR_MIN converted to CHAR_MIN char4 c = convert_char4_sat( s ); 
float4 f; // values implementation defined for // f > INT_MAX, f < INT_MIN or NaN int4 i = convert_int4( f ); // values > INT_MAX clamp to INT_MAX, values < INT_MIN clamp // to INT_MIN. NaN should produce 0. // The _rtz rounding mode is // used to produce the integer values. int4 i2 = convert_int4_sat( f ); // similar to convert_int4, except that // floatingpoint values are rounded to the nearest // integer instead of truncated int4 i3 = convert_int4_rte( f ); // similar to convert_int4_sat, except that // floatingpoint values are rounded to the // nearest integer instead of truncated int4 i4 = convert_int4_sat_rte( f ); 
int4 i; // convert ints to floats using the current rounding mode. float4 f = convert_float4( i ); // convert ints to floats. integer values that cannot // be exactly represented as floats should round up to the // next representable float. float4 f = convert_float4_rtp( i ); 