1ABS(3)                     Linux Programmer's Manual                    ABS(3)
2
3
4

NAME

6       abs, labs, llabs, imaxabs - compute the absolute value of an integer
7

SYNOPSIS

9       #include <stdlib.h>
10
11       int abs(int j);
12       long int labs(long int j);
13       long long int llabs(long long int j);
14
15       #include <inttypes.h>
16
17       intmax_t imaxabs(intmax_t j);
18
19   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
20
21       llabs(): _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE; or cc -std=c99
22

DESCRIPTION

24       The  abs() function computes the absolute value of the integer argument
25       j.  The labs(), llabs() and imaxabs() functions  compute  the  absolute
26       value  of  the argument j of the appropriate integer type for the func‐
27       tion.
28

RETURN VALUE

30       Returns the absolute value of the integer argument, of the  appropriate
31       integer type for the function.
32

CONFORMING TO

34       SVr4,  POSIX.1-2001,  4.3BSD,  C99.   C89  only  includes the abs() and
35       labs() functions; the functions llabs() and  imaxabs()  were  added  in
36       C99.
37

NOTES

39       Trying  to  take the absolute value of the most negative integer is not
40       defined.
41
42       The llabs() function is included in glibc since version 2.0, but is not
43       in  libc5  or libc4.  The imaxabs() function is included in glibc since
44       version 2.1.1.
45
46       For  llabs()  to  be  declared,  it  may   be   necessary   to   define
47       _ISOC99_SOURCE  or  _ISOC9X_SOURCE  (depending on the version of glibc)
48       before including any standard headers.
49
50       GCC handles abs() and labs() as built-in functions.  GCC 3.0 also  han‐
51       dles llabs() and imaxabs() as built-ins.
52

SEE ALSO

54       cabs(3), ceil(3), fabs(3), floor(3), rint(3)
55

COLOPHON

57       This  page  is  part of release 3.22 of the Linux man-pages project.  A
58       description of the project, and information about reporting  bugs,  can
59       be found at http://www.kernel.org/doc/man-pages/.
60
61
62
63GNU                               2007-07-26                            ABS(3)
Impressum