labs -- Integer Conversion: Absolute Value


SYNOPSIS
#include <stdlib.h>
long int labs(long int j);
DESCRIPTION
labs
returns the absolute value of a long int
.
RETURN VALUE
labs
returns the absolute value of its argument. Both the result and the
argument are of long int
type.
IMPLEMENTATION
labs
is implemented as a macro that invokes the built-in abs
function.
EXAMPLE
#include <stdio.h>
#include <stdlib.h>
main()
{
long int a, c; /* The variable, a, can have a negative value. */
int b;
puts("Enter values for a (can be negative) and b:");
scanf("%ld %d", &a, &b);
c = labs(a*b); /* Calculate absolute value. */
printf("The absolute value of their product = %ldn", c );
}
RELATED FUNCTIONS
abs
, fabs
SEE ALSO
Mathematical Functions