]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/abs.3
_exit.2, brk.2, abs.3, acos.3, acosh.3, asin.3, asinh.3, atan.3, atan2.3, atanh.3...
[thirdparty/man-pages.git] / man3 / abs.3
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 2015-08-08 "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 .sp
41 .BI "int abs(int " j );
42 .br
43 .BI "long int labs(long int " j );
44 .br
45 .BI "long long int llabs(long long int " j );
46 .sp
47 .B #include <inttypes.h>
48 .sp
49 .BI "intmax_t imaxabs(intmax_t " j );
50 .fi
51 .sp
52 .in -4n
53 Feature Test Macro Requirements for glibc (see
54 .BR feature_test_macros (7)):
55 .in
56 .sp
57 .ad l
58 .BR llabs ():
59 .RS 4
60 _ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L
61 .br
62 or
63 .I cc\ -std=c99
64 .RE
65 .ad
66 .SH DESCRIPTION
67 The
68 .BR abs ()
69 function computes the absolute value of the integer
70 argument \fIj\fP.
71 The
72 .BR labs (),
73 .BR llabs ()
74 and
75 .BR imaxabs ()
76 functions compute the absolute value of the argument \fIj\fP of the
77 appropriate integer type for the function.
78 .SH RETURN VALUE
79 Returns the absolute value of the integer argument, of the appropriate
80 integer type for the function.
81 .SH ATTRIBUTES
82 For an explanation of the terms used in this section, see
83 .BR attributes (7).
84 .ad l
85 .TS
86 allbox;
87 lb lb lb
88 l l l.
89 Interface Attribute Value
90 T{
91 .BR abs (),
92 .BR labs (),
93 .BR llabs (),
94 .BR imaxabs ()
95 T} Thread safety MT-Safe
96 .TE
97 .ad
98 .SH CONFORMING TO
99 POSIX.1-2001, POSIX.1-2008, C99, SVr4, 4.3BSD.
100 .\" POSIX.1 (1996 edition) requires only the
101 .\" .BR abs ()
102 .\" function.
103 C89 only
104 includes the
105 .BR abs ()
106 and
107 .BR labs ()
108 functions; the functions
109 .BR llabs ()
110 and
111 .BR imaxabs ()
112 were added in C99.
113 .SH NOTES
114 Trying to take the absolute value of the most negative integer
115 is not defined.
116 .PP
117 The
118 .BR llabs ()
119 function is included in glibc since version 2.0.
120 The
121 .BR imaxabs ()
122 function is included in
123 glibc since version 2.1.1.
124 .PP
125 For
126 .BR llabs ()
127 to be declared, it may be necessary to define
128 \fB_ISOC99_SOURCE\fP or \fB_ISOC9X_SOURCE\fP (depending on the
129 version of glibc) before including any standard headers.
130 .PP
131 By default,
132 GCC handles
133 .BR abs (),
134 .BR labs (),
135 and (since GCC 3.0)
136 .BR llabs ()
137 and
138 .BR imaxabs ()
139 as built-in functions.
140 .SH SEE ALSO
141 .BR cabs (3),
142 .BR ceil (3),
143 .BR fabs (3),
144 .BR floor (3),
145 .BR rint (3)