A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://en.cppreference.com/w/cpp/language/../../cpp/../c/header/../numeric/complex/cabs.html below:

cabsf, cabs, cabsl - cppreference.com

(1) (since C99) (2) (since C99) long double cabsl( long double complex z ); (3) (since C99)

#define fabs( z )

(4) (since C99)

1-3) Computes the complex absolute value (also known as norm, modulus, or magnitude) of z.

4)

Type-generic macro: if

z

has type

long double complex

or

long double imaginary

,

cabsl

is called. If

z

has type

float complex

or

float imaginary

,

cabsf

is called. If

z

has type

double complex

or

double imaginary

,

cabs

is called. For real and integer types, the corresponding version of

fabs

is called.

[edit] Parameters [edit] Return value

If no errors occur, returns the absolute value (norm, magnitude) of z.

Errors and special cases are handled as if the function is implemented as hypot(creal(z), cimag(z))

[edit] Example
#include <stdio.h>
#include <complex.h>
 
int main(void)
{
    double complex z = 1.0 + 1.0*I;
    printf("%.1f%+.1fi cartesian is rho=%f theta=%f polar\n",
           creal(z), cimag(z), cabs(z), carg(z));
}

Output:

1.0+1.0i cartesian is rho=1.414214 theta=0.785398 polar
[edit] References
[edit] See also computes the phase angle of a complex number
(function) [edit] computes absolute value of an integral value (\(\small{|x|}\)|x|)
(function) [edit] computes absolute value of a floating-point value (\(\small{|x|}\)|x|)
(function) [edit] computes square root of the sum of the squares of two given numbers (\(\scriptsize{\sqrt{x^2+y^2} }\)√x2
+y2
)
(function) [edit]

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4