So I have an openCL program where some of the variables are in float2 and some are in double2. And I would like to either upcast or downcast these variables but I am not sure how to do it. I tried to explicitly casting it like how I would normally do for float and double but it didn’t work.
float2 a,b;
double2 c,d;
a = (float2)(c+d); //didnt work
a = float2(c+d); //didnt work
Maybe I am not understanding the type “float2” and “double2”, could someone tell me how to cast them in order to work properly?
Thanks in advance.
The floatn and doublen type families represent vectors of values (in your case they have 2 members). A C-style conversion does not work on them.
There is a family of conversion functions that work for vectors that look like this:
However, reading the documentation here it looks like conversion from/to double2 is not supported. That leaves you with the option of performing the conversions manually: