[Previous]
[Contents]
[Next]

cabs()

compute the absolute value of a complex number

Synopsis:

#include <math.h>
double cabs( struct _complex value );

struct _complex {
    double  x;    /* real part */
    double  y;    /* imaginary part */
};

Description:

The cabs() function computes the absolute value of the complex number value, by a calculation that's equivalent to

sqrt( (value.x*value.x) + (value.y*value.y) )

In certain cases, overflow errors may occur, which will cause the matherr() routine to be invoked.

Returns:

The absolute value.

Examples:

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

struct _complex c = { -3.0, 4.0 };

void main()
  {
    printf( "%f\n", cabs( c ) );
  }

produces the output:

5.000000

Classification:

WATCOM

Safety:
Interrupt handler No
Signal handler No
Thread Yes

See also:

matherr()


[Previous]
[Contents]
[Next]