cargf, carg, cargl

Header: <complex.h>

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

# Declarations

float cargf( float complex z );

(since C99)

double carg( double complex z );

(since C99)

long double cargl( long double complex z );

(since C99)

#define carg( z )

(since C99)

# Parameters

# Return value

If no errors occur, returns the phase angle of z in the interval [−π; π].

# Example

#include <stdio.h>
#include <complex.h>
 
int main(void) 
{
    double complex z1 = 1.0+0.0*I;
    printf("phase angle of %.1f%+.1fi is %f\n", creal(z1), cimag(z1), carg(z1));
 
    double complex z2 = 0.0+1.0*I;
    printf("phase angle of %.1f%+.1fi is %f\n", creal(z2), cimag(z2), carg(z2));
 
    double complex z3 = -1.0+0.0*I;
    printf("phase angle of %.1f%+.1fi is %f\n", creal(z3), cimag(z3), carg(z3));
 
    double complex z4 = conj(z3); // or CMPLX(-1, -0.0)
    printf("phase angle of %.1f%+.1fi (the other side of the cut) is %f\n",
             creal(z4), cimag(z4), carg(z4));
}

# See also