]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/abs.3
Various pages: [GPL-2.0-only] Use SPDX-License-Identifier
[thirdparty/man-pages.git] / man3 / abs.3
CommitLineData
fea681da
MK
1.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2.\"
93015253 3.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
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.
c13182ef 12.\"
fea681da
MK
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.
c13182ef 20.\"
fea681da
MK
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 23.\" %%%LICENSE_END
fea681da
MK
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.\"
1d767b55 34.TH ABS 3 2021-03-22 "GNU" "Linux Programmer's Manual"
fea681da
MK
35.SH NAME
36abs, labs, llabs, imaxabs \- compute the absolute value of an integer
37.SH SYNOPSIS
38.nf
39.B #include <stdlib.h>
68e4db0a 40.PP
fea681da 41.BI "int abs(int " j );
ae85f653
AC
42.BI "long labs(long " j );
43.BI "long long llabs(long long " j );
eaa18d3c 44.PP
fea681da 45.B #include <inttypes.h>
68e4db0a 46.PP
fea681da
MK
47.BI "intmax_t imaxabs(intmax_t " j );
48.fi
68e4db0a 49.PP
d39ad78f 50.RS -4
cc4615cc
MK
51Feature Test Macro Requirements for glibc (see
52.BR feature_test_macros (7)):
d39ad78f 53.RE
68e4db0a 54.PP
cc4615cc 55.BR llabs ():
9d2adbae 56.nf
5c10d2c5 57 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
9d2adbae 58.fi
fea681da 59.SH DESCRIPTION
60a90ecd
MK
60The
61.BR abs ()
62function computes the absolute value of the integer
c13182ef 63argument \fIj\fP.
60a90ecd
MK
64The
65.BR labs (),
d556548b 66.BR llabs (),
60a90ecd
MK
67and
68.BR imaxabs ()
fea681da
MK
69functions compute the absolute value of the argument \fIj\fP of the
70appropriate integer type for the function.
47297adb 71.SH RETURN VALUE
fea681da
MK
72Returns the absolute value of the integer argument, of the appropriate
73integer type for the function.
b6c6e0a3 74.SH ATTRIBUTES
9baacb39
MK
75For an explanation of the terms used in this section, see
76.BR attributes (7).
77.ad l
c466875e 78.nh
9baacb39
MK
79.TS
80allbox;
c466875e 81lbx lb lb
9baacb39
MK
82l l l.
83Interface Attribute Value
84T{
b6c6e0a3
PH
85.BR abs (),
86.BR labs (),
87.BR llabs (),
b6c6e0a3 88.BR imaxabs ()
9baacb39
MK
89T} Thread safety MT-Safe
90.TE
c466875e 91.hy
9baacb39 92.ad
c466875e 93.sp 1
47297adb 94.SH CONFORMING TO
c5195941 95POSIX.1-2001, POSIX.1-2008, C99, SVr4, 4.3BSD.
33a0ccb2 96.\" POSIX.1 (1996 edition) requires only the
a4401275
MK
97.\" .BR abs ()
98.\" function.
68e1685c 99C89 only
60a90ecd
MK
100includes the
101.BR abs ()
102and
103.BR labs ()
104functions; the functions
105.BR llabs ()
106and
107.BR imaxabs ()
108were added in C99.
fea681da
MK
109.SH NOTES
110Trying to take the absolute value of the most negative integer
111is not defined.
112.PP
60a90ecd
MK
113The
114.BR llabs ()
2de012be 115function is included in glibc since version 2.0.
60a90ecd
MK
116The
117.BR imaxabs ()
118function is included in
fea681da
MK
119glibc since version 2.1.1.
120.PP
60a90ecd
MK
121For
122.BR llabs ()
123to be declared, it may be necessary to define
fea681da
MK
124\fB_ISOC99_SOURCE\fP or \fB_ISOC9X_SOURCE\fP (depending on the
125version of glibc) before including any standard headers.
126.PP
63fe5027 127By default,
60a90ecd 128GCC handles
36ad6ae0
MK
129.BR abs (),
130.BR labs (),
131and (since GCC 3.0)
60a90ecd
MK
132.BR llabs ()
133and
134.BR imaxabs ()
36ad6ae0 135as built-in functions.
47297adb 136.SH SEE ALSO
36268806 137.BR cabs (3),
fea681da
MK
138.BR ceil (3),
139.BR fabs (3),
140.BR floor (3),
141.BR rint (3)