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