### _cabs -- Calculate Absolute Value of Complex Number

Format

>     #include <math.h>
>     double _cabs(struct complex z);

Language Level: Extension
_cabs calculates the absolute value of a complex number. This complex number is represented as a structure with the tag complex containing the real and imaginary parts. The following type declaration is in <math.h>:

> `struct complex {double x,y;};`

A call to _cabs is equivalent to:

> `sqrt(z.x * z.x + z.y * z.y)`

Return Value
_cabs returns the absolute value as a double value. If an overflow results, _cabs calls the _matherr routine and, if necessary, sets errno to ERANGE and returns the value HUGE_VAL.

Example
The following program computes the absolute value of the complex number (3.0, 4.0).

    #include <math.h>
    #include <stdio.h>

    int main(void)
    {
       struct complex value;
       double d;

       value.x = 3.0;
       value.y = 4.0;
       d = _cabs(value);
       printf("The complex absolute value of %f and %f is %f\n", value.x, value.y, d
          );
       return 0;

       /****************************************************************************
          The output should be:

          The complex absolute value of 3.000000 and 4.000000 is 5.000000
       ****************************************************************************/
    }

abs -- Calculate Integer Absolute Value
fabs -- Calculate Floating-Point Absolute Value
hypot -- Calculate Hypotenuse
labs -- Calculate Absolute Value of Long Integer
_matherr -- Process Math Library Errors
sqrt -- Calculate Square Root
<math.h>