]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/abs.3
All pages: Replace the 4th argument to .TH by "Linux man-pages (unreleased)"
[thirdparty/man-pages.git] / man3 / abs.3
CommitLineData
fea681da
MK
1.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2.\"
5fbde956 3.\" SPDX-License-Identifier: Linux-man-pages-copyleft
fea681da
MK
4.\"
5.\" References consulted:
6.\" Linux libc source code
7.\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
8.\" 386BSD man pages
9.\" Modified Mon Mar 29 22:31:13 1993, David Metcalfe
10.\" Modified Sun Jun 6 23:27:50 1993, David Metcalfe
11.\" Modified Sat Jul 24 21:45:37 1993, Rik Faith (faith@cs.unc.edu)
12.\" Modified Sat Dec 16 15:02:59 2000, Joseph S. Myers
13.\"
7bd6328f 14.TH ABS 3 2021-03-22 "Linux man-pages (unreleased)" "Linux Programmer's Manual"
fea681da
MK
15.SH NAME
16abs, labs, llabs, imaxabs \- compute the absolute value of an integer
b813014f
AC
17.SH LIBRARY
18Standard C library
19.RI ( libc ", " \-lc )
fea681da
MK
20.SH SYNOPSIS
21.nf
22.B #include <stdlib.h>
68e4db0a 23.PP
fea681da 24.BI "int abs(int " j );
ae85f653
AC
25.BI "long labs(long " j );
26.BI "long long llabs(long long " j );
eaa18d3c 27.PP
fea681da 28.B #include <inttypes.h>
68e4db0a 29.PP
fea681da
MK
30.BI "intmax_t imaxabs(intmax_t " j );
31.fi
68e4db0a 32.PP
d39ad78f 33.RS -4
cc4615cc
MK
34Feature Test Macro Requirements for glibc (see
35.BR feature_test_macros (7)):
d39ad78f 36.RE
68e4db0a 37.PP
cc4615cc 38.BR llabs ():
9d2adbae 39.nf
5c10d2c5 40 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
9d2adbae 41.fi
fea681da 42.SH DESCRIPTION
60a90ecd
MK
43The
44.BR abs ()
45function computes the absolute value of the integer
c13182ef 46argument \fIj\fP.
60a90ecd
MK
47The
48.BR labs (),
d556548b 49.BR llabs (),
60a90ecd
MK
50and
51.BR imaxabs ()
fea681da
MK
52functions compute the absolute value of the argument \fIj\fP of the
53appropriate integer type for the function.
47297adb 54.SH RETURN VALUE
fea681da
MK
55Returns the absolute value of the integer argument, of the appropriate
56integer type for the function.
b6c6e0a3 57.SH ATTRIBUTES
9baacb39
MK
58For an explanation of the terms used in this section, see
59.BR attributes (7).
60.ad l
c466875e 61.nh
9baacb39
MK
62.TS
63allbox;
c466875e 64lbx lb lb
9baacb39
MK
65l l l.
66Interface Attribute Value
67T{
b6c6e0a3
PH
68.BR abs (),
69.BR labs (),
70.BR llabs (),
b6c6e0a3 71.BR imaxabs ()
9baacb39
MK
72T} Thread safety MT-Safe
73.TE
c466875e 74.hy
9baacb39 75.ad
c466875e 76.sp 1
3113c7f3 77.SH STANDARDS
c5195941 78POSIX.1-2001, POSIX.1-2008, C99, SVr4, 4.3BSD.
33a0ccb2 79.\" POSIX.1 (1996 edition) requires only the
a4401275
MK
80.\" .BR abs ()
81.\" function.
68e1685c 82C89 only
60a90ecd
MK
83includes the
84.BR abs ()
85and
86.BR labs ()
87functions; the functions
88.BR llabs ()
89and
90.BR imaxabs ()
91were added in C99.
fea681da
MK
92.SH NOTES
93Trying to take the absolute value of the most negative integer
94is not defined.
95.PP
60a90ecd
MK
96The
97.BR llabs ()
2de012be 98function is included in glibc since version 2.0.
60a90ecd
MK
99The
100.BR imaxabs ()
101function is included in
fea681da
MK
102glibc since version 2.1.1.
103.PP
60a90ecd
MK
104For
105.BR llabs ()
106to be declared, it may be necessary to define
fea681da
MK
107\fB_ISOC99_SOURCE\fP or \fB_ISOC9X_SOURCE\fP (depending on the
108version of glibc) before including any standard headers.
109.PP
63fe5027 110By default,
60a90ecd 111GCC handles
36ad6ae0
MK
112.BR abs (),
113.BR labs (),
114and (since GCC 3.0)
60a90ecd
MK
115.BR llabs ()
116and
117.BR imaxabs ()
36ad6ae0 118as built-in functions.
47297adb 119.SH SEE ALSO
36268806 120.BR cabs (3),
fea681da
MK
121.BR ceil (3),
122.BR fabs (3),
123.BR floor (3),
124.BR rint (3)