-
Book Overview & Buying
-
Table Of Contents
OpenCL Programming by Example
By :
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 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 corresponding hex representation is 0x3F800000. When you convert a float value to an int, the compiler will usually throw a warning. To avoid that you explicitly cast the scalar data types. Example:
float f = 2.0f; int i = (int) f;
Explicit cast of vector...
Change the font size
Change margin width
Change background colour