Consider the following code performing operations on complex numbers with C/C++'s float:

```
float real_part = log(3.f);
float imag_part = 0.f;
float2 complex_number3a, complex_number3b;
complex_number3a.x=imag_part;
complex_number3a.y=real_part;
complex_number3b.x=complex_number3a.x*complex_number3a.x-complex_number3a.y*complex_number3a.y;
complex_number3b.y=complex_number3a.x*complex_number3a.y+complex_number3a.y*complex_number3a.x;
```

The result will be

```
complex_number3b.x= -1.20695
complex_number3b.y= 0
angle= 3.14159
```

where angle is the phase of the complex number and, in this case, is pi.

Now consider the following code performing the same operations using CUDA’s float2:

```
complex_number3a.x=-imag_part;
complex_number3a.y=real_part;
complex_number3b.x=complex_number3a.x*complex_number3a.x-complex_number3a.y*complex_number3a.y;
complex_number3b.y=complex_number3a.x*complex_number3a.y+complex_number3a.y*complex_number3a.x;
```

The result will be

```
complex_number3b.x= -1.20695
complex_number3b.y= -0
angle= -3.14159
```

The imaginary part of the result is -0 which makes the phase of the result be -pi.

Although still accomplishing with the principal argument of a complex number and with the signed property of floating point’s 0, this changes is a problem when one is defining functions of complex numbers. For example, if one is defining sqrt of a float2 number by the de Moiver formula, this will change the sign of the imaginary part of the result to a wrong value.

How to deal with this effect?