cabsf, cabs, cabsl - cppreference.com

##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# cabsf, cabs, cabsl

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

Defined in header `<complex.h>` |  |
float cabsf( float complex z ); |  | (since C99)
double cabs( double complex z ); |  | (since C99)
long double cabsl( long double complex z ); |  | (since C99)

Computes the complex absolute value of `z`.

### [edit] Parameters

z | - | complex argument

### [edit] Return value

The complex absolute value of `z`.

### [edit] Example

Run this code

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

    int main(void)
    {
        double x = cabs(1.0 + 2.0*I);
        printf("%f\n", x);

        return 0;
    }

Output:

    2.236068

### [edit] See also

cargcargfcargl (C99)(C99)(C99) | computes the phase angle of a complex number (function) [edit]
abslabsllabs (C99) | computes absolute value of an integral value (|x|) (function) [edit]
fabsfabsffabsl (C99)(C99) | computes absolute value of a floating-point value (|x|) (function) [edit]
hypothypotfhypotl (C99)(C99)(C99) | computes square root of the sum of the squares of two given numbers (√x2 +y2 ) (function) [edit]
C++ documentation for abs

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