I have forgotten

labs

Return the absolute value of a long integer
View other versions (4)

Interface

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

Description

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

$|j|&space;:=&space;\left\{&space;\begin{array}{ll}&space;j,&space;&&space;j&space;\geq&space;0,&space;\\&space;-j,&space;&&space;j&space;<&space;0.&space;\end{array}&space;&space;\right.$

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