These functions are provided for obtaining the absolute value (or magnitude) of a number. The absolute value of a real number x is x is x is positive, -x if x is negative. For a complex number z, whose real part is x and whose imaginary part is y, the absolute value is sqrt (x*x + y*y)
.
Prototypes for abs
and labs
are in `stdlib.h'; fabs
and cabs
are declared in `math.h'.
Most computers use a two's complement integer representation, in which the absolute value of INT_MIN
(the smallest possible int
) cannot be represented; thus, abs (INT_MIN)
is not defined.
abs
, except that both the argument and result are of type long int
rather than int
.
cabs
function returns the absolute value of the complex number z, whose real part is z.real
and whose imaginary part is z.imag
. (See also the function hypot
in Exponents and Logarithms.) The value is:
sqrt (z.real*z.real + z.imag*z.imag)