abs(3) CLIX abs(3)
NAME
abs, labs - Returns an integer absolute value
LIBRARY
Standard C Library (libc.a)
SYNOPSIS
#include <stdlib.h>
int abs(
int i );
int labs(
long lval );
PARAMETERS
i Specifies an integer operand.
lval Specifies a long operand.
DESCRIPTION
The abs() function returns the absolute value of its integer operand. The
labs() function returns the absolute value of its long operand.
In two's complement representation, the absolute value of the negative
integer with largest magnitude is undefined. Some implementations trap
this error and others ignore it.
EXAMPLES
This example gets the absolute value of a command line argument by
compiling the following program using this command:
cc -o abs absexamp.c -lm
main(argc,argv)
int argc
char **argv;
{
char c;
int number;
int answer;
number = atoj(argv[1]);
answer = abs(number);
printf("The answer is %d.O\n",answer);
2/94 - Intergraph Corporation 1
abs(3) CLIX abs(3)
}
This program is run by giving the abs command a positive or negative
integer as its argument at the command line.
RETURN VALUES
Both the abs() and labs() functions return the absolute value of their
arguments.
RELATED INFORMATION
Functions: floor(3)
2 Intergraph Corporation - 2/94