function

labs

<cstdlib>
long int labs ( long int n );
Absolute value
Returns the absolute value of parameter n ( /n/ ).

This is the long int version of abs.

Parameters

n
Integral value.

Return Value

The absolute value of n.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
/* labs example */
#include <stdio.h>
#include <stdlib.h>

int main ()
{
  long int n,m;
  n=labs(65537L);
  m=labs(-100000L);
  printf ("n=%ld\n",n);
  printf ("m=%ld\n",m);
  return 0;
}


Output:

n=65537
m=100000

See also