Cast float2 to double2 and vice versa

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 raise or lower these variables, but I'm not sure how to do this. I tried to explicitly sketch it, as usual, for float and double, but that didn't work.

float2 a,b; double2 c,d; a = (float2)(c+d); //didnt work a = float2(c+d); //didnt work 

Perhaps I do not understand the type of "float2" and "double2", can someone tell me how to distinguish them in order to work correctly?

Thanks in advance.

+4
source share
1 answer

The floatn and doublelen type families represent value vectors (in your case, they have 2 members). C style conversion doesn't work for them.

There is a family of conversion functions that work for vectors that look like this:

 convert_float2(vec2) 

However, after reading the documentation here , it looks like conversion from / to double2 is not supported. This leaves you the option to perform manual conversions:

 ax = float(cx + dx); ay = float(cy + dy); 
+4
source

All Articles