]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/abs.3
ffix
[thirdparty/man-pages.git] / man3 / abs.3
CommitLineData
fea681da
MK
1.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2.\"
3.\" Permission is granted to make and distribute verbatim copies of this
4.\" manual provided the copyright notice and this permission notice are
5.\" preserved on all copies.
6.\"
7.\" Permission is granted to copy and distribute modified versions of this
8.\" manual under the conditions for verbatim copying, provided that the
9.\" entire resulting derived work is distributed under the terms of a
10.\" permission notice identical to this one.
c13182ef 11.\"
fea681da
MK
12.\" Since the Linux kernel and libraries are constantly changing, this
13.\" manual page may be incorrect or out-of-date. The author(s) assume no
14.\" responsibility for errors or omissions, or for damages resulting from
15.\" the use of the information contained herein. The author(s) may not
16.\" have taken the same level of care in the production of this manual,
17.\" which is licensed free of charge, as they might when working
18.\" professionally.
c13182ef 19.\"
fea681da
MK
20.\" Formatted or processed versions of this manual, if unaccompanied by
21.\" the source, must acknowledge the copyright and authors of this work.
22.\"
23.\" References consulted:
24.\" Linux libc source code
25.\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
26.\" 386BSD man pages
27.\" Modified Mon Mar 29 22:31:13 1993, David Metcalfe
28.\" Modified Sun Jun 6 23:27:50 1993, David Metcalfe
29.\" Modified Sat Jul 24 21:45:37 1993, Rik Faith (faith@cs.unc.edu)
30.\" Modified Sat Dec 16 15:02:59 2000, Joseph S. Myers
31.\"
32.TH ABS 3 2000-12-17 "GNU" "Linux Programmer's Manual"
33.SH NAME
34abs, labs, llabs, imaxabs \- compute the absolute value of an integer
35.SH SYNOPSIS
36.nf
37.B #include <stdlib.h>
38.sp
39.BI "int abs(int " j );
40.br
41.BI "long int labs(long int " j );
42.br
43.BI "long long int llabs(long long int " j );
44.sp
45.B #include <inttypes.h>
46.sp
47.BI "intmax_t imaxabs(intmax_t " j );
48.fi
49.SH DESCRIPTION
60a90ecd
MK
50The
51.BR abs ()
52function computes the absolute value of the integer
c13182ef 53argument \fIj\fP.
60a90ecd
MK
54The
55.BR labs (),
56.BR llabs ()
57and
58.BR imaxabs ()
fea681da
MK
59functions compute the absolute value of the argument \fIj\fP of the
60appropriate integer type for the function.
61.SH "RETURN VALUE"
62Returns the absolute value of the integer argument, of the appropriate
63integer type for the function.
64.SH "CONFORMING TO"
c13182ef 65SVr4, POSIX.1-2001, 4.3BSD, C99.
60a90ecd 66.\" POSIX.1 (1996 edition) only requires the
a4401275
MK
67.\" .BR abs ()
68.\" function.
68e1685c 69C89 only
60a90ecd
MK
70includes the
71.BR abs ()
72and
73.BR labs ()
74functions; the functions
75.BR llabs ()
76and
77.BR imaxabs ()
78were added in C99.
fea681da
MK
79.SH NOTES
80Trying to take the absolute value of the most negative integer
81is not defined.
82.PP
60a90ecd
MK
83The
84.BR llabs ()
85function is included in glibc since version 2.0, but
c13182ef 86is not in libc5 or libc4.
60a90ecd
MK
87The
88.BR imaxabs ()
89function is included in
fea681da
MK
90glibc since version 2.1.1.
91.PP
60a90ecd
MK
92For
93.BR llabs ()
94to be declared, it may be necessary to define
fea681da
MK
95\fB_ISOC99_SOURCE\fP or \fB_ISOC9X_SOURCE\fP (depending on the
96version of glibc) before including any standard headers.
97.PP
60a90ecd
MK
98GCC handles
99.BR abs ()
100and
101.BR labs ()
102as builtin functions.
103GCC 3.0 also handles
104.BR llabs ()
105and
106.BR imaxabs ()
107as builtins.
fea681da 108.SH "SEE ALSO"
36268806 109.BR cabs (3),
fea681da
MK
110.BR ceil (3),
111.BR fabs (3),
112.BR floor (3),
113.BR rint (3)