OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / 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  2014-08-19 "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 _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE ||
61 _POSIX_C_SOURCE\ >=\ 200112L;
62 .br
63 or
64 .I cc\ -std=c99
65 .RE
66 .ad
67 .SH DESCRIPTION
68 The
69 .BR abs ()
70 function computes the absolute value of the integer
71 argument \fIj\fP.
72 The
73 .BR labs (),
74 .BR llabs ()
75 and
76 .BR imaxabs ()
77 functions compute the absolute value of the argument \fIj\fP of the
78 appropriate integer type for the function.
79 .SH RETURN VALUE
80 Returns the absolute value of the integer argument, of the appropriate
81 integer type for the function.
82 .SH ATTRIBUTES
83 .SS Multithreading (see pthreads(7))
84 The
85 .BR abs (),
86 .BR labs (),
87 .BR llabs (),
88 and
89 .BR imaxabs ()
90 functions are thread-safe.
91 .SH CONFORMING TO
92 SVr4, POSIX.1-2001, 4.3BSD, C99.
93 .\" POSIX.1 (1996 edition) requires only the
94 .\" .BR abs ()
95 .\" function.
96 C89 only
97 includes the
98 .BR abs ()
99 and
100 .BR labs ()
101 functions; the functions
102 .BR llabs ()
103 and
104 .BR imaxabs ()
105 were added in C99.
106 .SH NOTES
107 Trying to take the absolute value of the most negative integer
108 is not defined.
109 .PP
110 The
111 .BR llabs ()
112 function is included in glibc since version 2.0.
113 The
114 .BR imaxabs ()
115 function is included in
116 glibc since version 2.1.1.
117 .PP
118 For
119 .BR llabs ()
120 to be declared, it may be necessary to define
121 \fB_ISOC99_SOURCE\fP or \fB_ISOC9X_SOURCE\fP (depending on the
122 version of glibc) before including any standard headers.
123 .PP
124 By default,
125 GCC handles
126 .BR abs (),
127 .BR labs (),
128 and (since GCC 3.0)
129 .BR llabs ()
130 and
131 .BR imaxabs ()
132 as built-in functions.
133 .SH SEE ALSO
134 .BR cabs (3),
135 .BR ceil (3),
136 .BR fabs (3),
137 .BR floor (3),
138 .BR rint (3)
139 .SH COLOPHON
140 This page is part of release 3.79 of the Linux
141 .I man-pages
142 project.
143 A description of the project,
144 information about reporting bugs,
145 and the latest version of this page,
146 can be found at
147 \%http://www.kernel.org/doc/man\-pages/.