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

DESCRIPTION

20       The  abs() function computes the absolute value of the integer argument
21       j.  The labs(), llabs() and imaxabs() functions  compute  the  absolute
22       value  of  the argument j of the appropriate integer type for the func‐
23       tion.
24

RETURN VALUE

26       Returns the absolute value of the integer argument, of the  appropriate
27       integer type for the function.
28

CONFORMING TO

30       SVr4,  POSIX.1-2001,  4.3BSD,  C99.   C89  only  includes the abs() and
31       labs() functions; the functions llabs() and  imaxabs()  were  added  in
32       C99.
33

NOTES

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

SEE ALSO

50       cabs(3), ceil(3), fabs(3), floor(3), rint(3)
51
52
53
54GNU                               2000-12-17                            ABS(3)
Impressum