C Programming/math.h/labs

From Wikibooks, open books for an open world
Jump to navigation Jump to search

In C language the function labs is included in header file stdlib.h. The abs() function computes and returns the absolute value of the integer argument i. The labs() function computes and returns the absolute value of the long integer argument, of the appropriate long integer type for the function. The llabs() function computes and returns the absolute value of long long integer argument.

Description[edit | edit source]

The labs() is a library function. It is used under #include<stdlib.h> header file. This function computes the absolute value of the long integer argument i. It also returns the absolute value of the argument. That is, if i is negative, the result is opposite of i, but if i is non-negative the result is i.

Required header files[edit | edit source]

  1. include<stdio.h>
  2. include<stdlib.h>

Syntax[edit | edit source]

  1. include<stdlib.h>

long int labs(long int i);


References[edit | edit source]

http://cplusplus.com/reference/clibrary/cstdlib/labs/
http://linux.die.net/man/3/labs