www.delorie.com/gnu/docs/glibc/libc_413.html | search |
Buy the book! | |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These functions are provided for obtaining the absolute value (or
magnitude) of a number. The absolute value of a real number
x is x if 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
, labs
and llabs
are in `stdlib.h';
imaxabs
is declared in `inttypes.h';
fabs
, fabsf
and fabsl
are declared in `math.h'.
cabs
, cabsf
and cabsl
are declared in `complex.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.
llabs
and imaxdiv
are new to ISO C99.
See 20.1 Integers for a description of the intmax_t
type.
sqrt (creal (z) * creal (z) + cimag (z) * cimag (z)) |
This function should always be used instead of the direct formula
because it takes special care to avoid losing precision. It may also
take advantage of hardware support for this operation. See hypot
in 19.4 Exponentiation and Logarithms.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
webmaster | delorie software privacy |
Copyright © 2003 by The Free Software Foundation | Updated Jun 2003 |