abs
integer absolute value function
You're viewing an older version of this page (#4035). View the current version.
INTERFACE
#include <stdlib.h> int abs ( int j )
DESCRIPTION
The abs function computes the absolute value of the integer \c j, denoted by
and defined through:
(1)
Example 1
Workings
\code #include <stdio.h> #include <stdlib.h> int main() { int a = -127; printf("|a| = %d
", abs(a)); return 0; } \endcode
Solution
Output:
|a| = 127RETURN VALUES
The abs function returns the absolute value.
SEE ALSO
BUGS
The absolute value of the most negative integer remains negative.