##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# cargf, carg, cargl

From cppreference.com
< c‎ | numeric‎ | complex

Defined in header `<complex.h>` |  |
float cargf( float complex z ); |  | (since C99)
double carg( double complex z ); |  | (since C99)
long double cargl( long double complex z ); |  | (since C99)

Computes the argument (also called phase angle) of `z`, with a branch cut along the negative real axis.

### [edit] Parameters

z | - | complex argument

### [edit] Return value

The argument of `z` in the interval (−π; π).

### [edit] Example

Run this code

    #include <stdio.h>
    #include <complex.h>
    #include <math.h>

    int main(void)
    {
        double complex z;                 /* complex number     */
        double phase;                     /* phase angle        */
        double rtod = 180.0/acos(-1.0);   /* radians to degrees */

        z = 0.0+0.0*I;
        phase = carg(z);
        printf("%9f radians,  %6.1f degrees\n", phase,phase*rtod);

        z = 1.0+1.0*I;
        phase = carg(z);
        printf("%9f radians,  %6.1f degrees\n", phase,phase*rtod);

        z = -1.0+1.0*I;
        phase = carg(z);
        printf("%9f radians,  %6.1f degrees\n", phase,phase*rtod);

        z = -1.0-1.0*I;
        phase = carg(z);
        printf("%9f radians,  %6.1f degrees\n", phase,phase*rtod);

        z = 1.0-1.0*I;
        phase = carg(z);
        printf("%9f radians,  %6.1f degrees\n", phase,phase*rtod);

        return 0;
    }

Output:

    0.000000 radians,     0.0 degrees
     0.785398 radians,    45.0 degrees
     2.356194 radians,   135.0 degrees
    -2.356194 radians,  -135.0 degrees
    -0.785398 radians,   -45.0 degrees

### [edit] See also

cabs cabsf cabsl (C99)(C99)(C99) | computes the magnitude of a complex number (function) [edit]
atan2 atan2f atan2l (C99)(C99) | computes arc tangent, using signs to determine quadrants (function) [edit]
C++ documentation for arg

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=c/numeric/complex/carg&oldid=71281"