ABS(3) Library Functions Manual ABS(3)

abs, labs, llabs, imaxabsreturn absolute value for integer types

Standard C Library (libc, -lc)
#include <stdlib.h>

int
abs(int i);

long
labs(long i);

long long
llabs(long long i);

#include <inttypes.h>

intmax_t
imaxabs(intmax_t i);

The (), (), (), and () functions compute the absolute value of i.

The abs(), labs(), llabs(), and imaxabs() functions return the absolute value.

cabs(3), fabs(3), floor(3), hypot(3)

The abs(), labs(), llabs(), and imaxabs() functions conform to and.

The abs() function first appeared in Version 6 AT&T UNIX. The labs() function first appeared in 4.3BSD. The llabs() and imaxabs() functions first appeared in FreeBSD 5.0.

The absolute value of the most negative integer remains negative.

November 14, 2001 Mac OS X 12