CodeCogs
HomeForumsCart
Login



Forgotten Password?

Or login with:

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

abs

Integer absolute value function

Interface

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

Description

The abs function computes the absolute value of the integer j, denoted by \inline |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.

Bugs

The absolute value of the most negative integer remains negative.

Last Modified: 23 Feb 12 @ 08:59     Page Rendered: 2022-03-14 15:47:05