wait.2: Add ESRCH for when pid == INT_MIN
[man-pages.git] / man3 / abs.3
blobafaf4f8d70c188cf690cd31f9b324baca28bfeb8
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" References consulted:
26 .\"     Linux libc source code
27 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
28 .\"     386BSD man pages
29 .\" Modified Mon Mar 29 22:31:13 1993, David Metcalfe
30 .\" Modified Sun Jun  6 23:27:50 1993, David Metcalfe
31 .\" Modified Sat Jul 24 21:45:37 1993, Rik Faith (faith@cs.unc.edu)
32 .\" Modified Sat Dec 16 15:02:59 2000, Joseph S. Myers
33 .\"
34 .TH ABS 3  2021-03-22 "GNU" "Linux Programmer's Manual"
35 .SH NAME
36 abs, labs, llabs, imaxabs \- compute the absolute value of an integer
37 .SH SYNOPSIS
38 .nf
39 .B #include <stdlib.h>
40 .PP
41 .BI "int abs(int " j );
42 .BI "long labs(long " j );
43 .BI "long long llabs(long long " j );
44 .PP
45 .B #include <inttypes.h>
46 .PP
47 .BI "intmax_t imaxabs(intmax_t " j );
48 .fi
49 .PP
50 .RS -4
51 Feature Test Macro Requirements for glibc (see
52 .BR feature_test_macros (7)):
53 .RE
54 .PP
55 .BR llabs ():
56 .nf
57     _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
58 .fi
59 .SH DESCRIPTION
60 The
61 .BR abs ()
62 function computes the absolute value of the integer
63 argument \fIj\fP.
64 The
65 .BR labs (),
66 .BR llabs (),
67 and
68 .BR imaxabs ()
69 functions compute the absolute value of the argument \fIj\fP of the
70 appropriate integer type for the function.
71 .SH RETURN VALUE
72 Returns the absolute value of the integer argument, of the appropriate
73 integer type for the function.
74 .SH ATTRIBUTES
75 For an explanation of the terms used in this section, see
76 .BR attributes (7).
77 .ad l
78 .nh
79 .TS
80 allbox;
81 lbx lb lb
82 l l l.
83 Interface       Attribute       Value
85 .BR abs (),
86 .BR labs (),
87 .BR llabs (),
88 .BR imaxabs ()
89 T}      Thread safety   MT-Safe
90 .TE
91 .hy
92 .ad
93 .sp 1
94 .SH CONFORMING TO
95 POSIX.1-2001, POSIX.1-2008, C99, SVr4, 4.3BSD.
96 .\" POSIX.1 (1996 edition) requires only the
97 .\" .BR abs ()
98 .\" function.
99 C89 only
100 includes the
101 .BR abs ()
103 .BR labs ()
104 functions; the functions
105 .BR llabs ()
107 .BR imaxabs ()
108 were added in C99.
109 .SH NOTES
110 Trying to take the absolute value of the most negative integer
111 is not defined.
114 .BR llabs ()
115 function is included in glibc since version 2.0.
117 .BR imaxabs ()
118 function is included in
119 glibc since version 2.1.1.
122 .BR llabs ()
123 to be declared, it may be necessary to define
124 \fB_ISOC99_SOURCE\fP or \fB_ISOC9X_SOURCE\fP (depending on the
125 version of glibc) before including any standard headers.
127 By default,
128 GCC handles
129 .BR abs (),
130 .BR labs (),
131 and (since GCC 3.0)
132 .BR llabs ()
134 .BR imaxabs ()
135 as built-in functions.
136 .SH SEE ALSO
137 .BR cabs (3),
138 .BR ceil (3),
139 .BR fabs (3),
140 .BR floor (3),
141 .BR rint (3)