CodeCogs
HomeForumsCart
Login



Forgotten Password?

Or login with:

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

labs

Return the absolute value of a long integer

Interface

#include <stdlib.h>
long labs (long j)

Description

The labs function returns the absolute value of the long integer j, denoted by \inline |j| and defined through:

Example 1

#include <stdio.h>
#include <stdlib.h>
 
int main()
{
  long int a = -231564565;
  printf("|a| = %ld\n", labs(a));
  return 0;
}

Output:
|a| = 231564565

Bugs

The absolute value of the most negative integer remains negative.

Last Modified: 18 Dec 11 @ 14:42     Page Rendered: 2022-03-14 15:47:11