]>
Commit | Line | Data |
---|---|---|
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 | .\" | |
460495ca | 34 | .TH ABS 3 2015-08-08 "GNU" "Linux Programmer's Manual" |
fea681da MK |
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 | |
cc4615cc MK |
51 | .sp |
52 | .in -4n | |
53 | Feature Test Macro Requirements for glibc (see | |
54 | .BR feature_test_macros (7)): | |
55 | .in | |
56 | .sp | |
e0a98111 | 57 | .ad l |
cc4615cc | 58 | .BR llabs (): |
e0a98111 | 59 | .RS 4 |
6c3f0228 MK |
60 | _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE || |
61 | _POSIX_C_SOURCE\ >=\ 200112L; | |
e0a98111 MK |
62 | .br |
63 | or | |
cc4615cc | 64 | .I cc\ -std=c99 |
c9f2ff9d | 65 | .RE |
e0a98111 | 66 | .ad |
fea681da | 67 | .SH DESCRIPTION |
60a90ecd MK |
68 | The |
69 | .BR abs () | |
70 | function computes the absolute value of the integer | |
c13182ef | 71 | argument \fIj\fP. |
60a90ecd MK |
72 | The |
73 | .BR labs (), | |
74 | .BR llabs () | |
75 | and | |
76 | .BR imaxabs () | |
fea681da MK |
77 | functions compute the absolute value of the argument \fIj\fP of the |
78 | appropriate integer type for the function. | |
47297adb | 79 | .SH RETURN VALUE |
fea681da MK |
80 | Returns the absolute value of the integer argument, of the appropriate |
81 | integer type for the function. | |
b6c6e0a3 | 82 | .SH ATTRIBUTES |
9baacb39 MK |
83 | For an explanation of the terms used in this section, see |
84 | .BR attributes (7). | |
85 | .ad l | |
86 | .TS | |
87 | allbox; | |
88 | lb lb lb | |
89 | l l l. | |
90 | Interface Attribute Value | |
91 | T{ | |
b6c6e0a3 PH |
92 | .BR abs (), |
93 | .BR labs (), | |
94 | .BR llabs (), | |
b6c6e0a3 | 95 | .BR imaxabs () |
9baacb39 MK |
96 | T} Thread safety MT-Safe |
97 | .TE | |
98 | .ad | |
47297adb | 99 | .SH CONFORMING TO |
c5195941 | 100 | POSIX.1-2001, POSIX.1-2008, C99, SVr4, 4.3BSD. |
33a0ccb2 | 101 | .\" POSIX.1 (1996 edition) requires only the |
a4401275 MK |
102 | .\" .BR abs () |
103 | .\" function. | |
68e1685c | 104 | C89 only |
60a90ecd MK |
105 | includes the |
106 | .BR abs () | |
107 | and | |
108 | .BR labs () | |
109 | functions; the functions | |
110 | .BR llabs () | |
111 | and | |
112 | .BR imaxabs () | |
113 | were added in C99. | |
fea681da MK |
114 | .SH NOTES |
115 | Trying to take the absolute value of the most negative integer | |
116 | is not defined. | |
117 | .PP | |
60a90ecd MK |
118 | The |
119 | .BR llabs () | |
2de012be | 120 | function is included in glibc since version 2.0. |
60a90ecd MK |
121 | The |
122 | .BR imaxabs () | |
123 | function is included in | |
fea681da MK |
124 | glibc since version 2.1.1. |
125 | .PP | |
60a90ecd MK |
126 | For |
127 | .BR llabs () | |
128 | to be declared, it may be necessary to define | |
fea681da MK |
129 | \fB_ISOC99_SOURCE\fP or \fB_ISOC9X_SOURCE\fP (depending on the |
130 | version of glibc) before including any standard headers. | |
131 | .PP | |
63fe5027 | 132 | By default, |
60a90ecd | 133 | GCC handles |
36ad6ae0 MK |
134 | .BR abs (), |
135 | .BR labs (), | |
136 | and (since GCC 3.0) | |
60a90ecd MK |
137 | .BR llabs () |
138 | and | |
139 | .BR imaxabs () | |
36ad6ae0 | 140 | as built-in functions. |
47297adb | 141 | .SH SEE ALSO |
36268806 | 142 | .BR cabs (3), |
fea681da MK |
143 | .BR ceil (3), |
144 | .BR fabs (3), | |
145 | .BR floor (3), | |
146 | .BR rint (3) |