Recover Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttp://yahoo.com/
ComputingCStdlib.h

abs

Integer absolute value function
+ View other versions (4)

Interface

#include <stdlib.h>
int abs (int j)

Description

The abs function computes the absolute value of the integer j, denoted by |j| and defined through:

Example 1

#include <stdio.h>
#include <stdlib.h>
 
int main()
{
  int a = -127;
  printf("|a| = %d\n", abs(a));
  return 0;
}

Output:
|a| = 127

Return Values

The abs function returns the absolute value.

See Also

labs, fabs, floor

Bugs

The absolute value of the most negative integer remains negative.
 

Page Comments

 
 Format Excel Equations

  You must login to leave a messge