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