Guardian C Library Calls Reference Manual
labs
3-102 128833—Guardian TNS C Library Calls Reference Manual
Reference to Library Calls
labs
The labs function returns the absolute value of its argument.
expr
is an expression whose value has type long.
Return Value
is the absolute value of expr.
Usage Guidelines
•
The absolute value of the most negative long integer (LONG_MIN) cannot be
represented.
Example
This example prints “The absolute value of -100000 is 100000.”
#include <stdioh>
#include <stdlibh>
int main(void)
{
long r, x;
x = -100000;
r = labs(x);
printf("The absolute value of %ld is %ld.", x, r);
}
#include <stdlibh>
long labs(long expr);