Name

labs - computes the absolute value of an integer

Library

libc.lib

Synopsis

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

Return values

The (labs, function, returns, the, absolute, value.);

Detailed description

The labs function returns the absolute value of the long integer j.


Examples

#include  <stdio.h>
#include  <stdlib.h>
 
int main( void )
{
   int    ix = -4, iy;
   long   lx = -41567L, ly;
   long long llx = -5343546758, lly;
 
   iy = abs( ix );
   printf( "The abs value of %d is %d\n", ix, iy);
 
   ly = labs( lx );
   printf( "The abs value of %ld is %ld\n", lx, ly);
 
   lly = llabs( llx );
   printf( "The abs value of %lld is %lld\n", llx, lly );
 
   return 0;
}

         

Output

The absolute value of -4 is 4
The absolute value of -41567 is 41567
The absolute value of -5343546758 is 5343546758

         

See also

abs, floor, llabs, math

Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top