absolute value of a complex number

You're viewing an older version of this page (#3345). View the current version.

View versions (3)

NAME

cabs, cabsf, cabsl

INTERFACE

#include <complex.h>

double cabs(double complex z ); float cabsf(float complex z ); long double cabsl(long double complex z );

DESCRIPTION

The cabs () function returns the absolute value of the complex number z = a+i*b. The result is a real number, i.e.

|z|=\sqrt{a^2+b^2
(1)

The function is actually an alias for hypot(a,b) = sqrt(a*a+b*b).

Link with -lm

CONFORMING TO

C99

SEE ALSO

abs (3), cimag (3), hypot (3), complex (7)

Compatibility

<table class="compat"> <tr><th></th><th>DOS</th><th>UNIX</th><th>Windows</th><th>ANSI C</th><th>C++ only</th></tr> <tr><td>cabs</td><td></td><td>&bull;</td><td>&bull;</td><td></td><td>&bull;</td></tr> </table>