Edit

Share via


carg, cargf, cargl

Retrieves the argument of a complex number, with a branch cut along the negative real axis.

Syntax

double carg(
   _Dcomplex z
);
float carg(
   _Fcomplex z
);  // C++ only
long double carg(
   _Lcomplex z
);  // C++ only
float cargf(
   _Fcomplex z
);
long double cargl(
   _Lcomplex z
);
#define carg(X) // Requires C11 or higher

Parameters

z
A complex number.

Return value

The argument (also known as the phase) of z. The result is in the interval [-π, +π].

Remarks

Because C++ allows overloading, you can call overloads of carg that take _Fcomplex or _Lcomplex values, and return float or long double values. In a C program, unless you're using the <tgmath.h> macro to call this function, carg always takes a _Dcomplex value and returns a double value.

If you use the <tgmath.h> carg() macro, the type of the argument determines which version of the function is selected. See Type-generic math for details.

Requirements

Routine C header C++ header
carg, cargf, cargl <complex.h> <ccomplex>
carg macro <tgmath.h>

For more compatibility information, see Compatibility.

See also

Alphabetical function reference
norm, normf, norml
creal, crealf, creall
cproj, cprojf, cprojl
conj, conjf, conjl
cimag, cimagf, cimagl
cabs, cabsf, cabsl