Conversions and type casts

All programming languages support converting a numerical data type to another numerical data type. There is also a need to reinterpret a data type in some other form, for example, if one wants to extract only the exponent component from a floating point data type, how can one do that? We will discuss the implicit and explicit type conversions, followed by reinterpreting the data types.

Implicit conversion

Implicit conversion refers to the conversion of a data in one type to another type, which is equivalent to the original data type. This conversion is allowed for basic data types, which is described in the table earlier. For example, the integer value 1 will be converted to an equivalent floating point value 1.0f. The ...

Get OpenCL Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.