Namespaces
Variants
Views
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

#include <stdio.h>
#include <complex.h>
 
int main()
{
 
    double x = cabs(1.0 + 2.0*I);
    printf("%f\n", x);
 
    return 0;
}

Output:

2.236068