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():
22           _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE ||
23           _POSIX_C_SOURCE >= 200112L;
24           or cc -std=c99
25

DESCRIPTION

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

RETURN VALUE

33       Returns  the absolute value of the integer argument, of the appropriate
34       integer type for the function.
35

ATTRIBUTES

37   Multithreading (see pthreads(7))
38       The abs(), labs(), llabs(), and imaxabs() functions are thread-safe.
39

CONFORMING TO

41       SVr4, POSIX.1-2001, 4.3BSD, C99.   C89  only  includes  the  abs()  and
42       labs()  functions;  the  functions  llabs() and imaxabs() were added in
43       C99.
44

NOTES

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

SEE ALSO

61       cabs(3), ceil(3), fabs(3), floor(3), rint(3)
62

COLOPHON

64       This page is part of release 3.53 of the Linux  man-pages  project.   A
65       description  of  the project, and information about reporting bugs, can
66       be found at http://www.kernel.org/doc/man-pages/.
67
68
69
70GNU                               2013-06-21                            ABS(3)
Impressum