]>
Commit | Line | Data |
---|---|---|
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 |
16 | abs, labs, llabs, imaxabs \- compute the absolute value of an integer | |
b813014f AC |
17 | .SH LIBRARY |
18 | Standard 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 |
34 | Feature 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 |
43 | The |
44 | .BR abs () | |
45 | function computes the absolute value of the integer | |
c13182ef | 46 | argument \fIj\fP. |
60a90ecd MK |
47 | The |
48 | .BR labs (), | |
d556548b | 49 | .BR llabs (), |
60a90ecd MK |
50 | and |
51 | .BR imaxabs () | |
fea681da MK |
52 | functions compute the absolute value of the argument \fIj\fP of the |
53 | appropriate integer type for the function. | |
47297adb | 54 | .SH RETURN VALUE |
fea681da MK |
55 | Returns the absolute value of the integer argument, of the appropriate |
56 | integer type for the function. | |
b6c6e0a3 | 57 | .SH ATTRIBUTES |
9baacb39 MK |
58 | For an explanation of the terms used in this section, see |
59 | .BR attributes (7). | |
60 | .ad l | |
c466875e | 61 | .nh |
9baacb39 MK |
62 | .TS |
63 | allbox; | |
c466875e | 64 | lbx lb lb |
9baacb39 MK |
65 | l l l. |
66 | Interface Attribute Value | |
67 | T{ | |
b6c6e0a3 PH |
68 | .BR abs (), |
69 | .BR labs (), | |
70 | .BR llabs (), | |
b6c6e0a3 | 71 | .BR imaxabs () |
9baacb39 MK |
72 | T} Thread safety MT-Safe |
73 | .TE | |
c466875e | 74 | .hy |
9baacb39 | 75 | .ad |
c466875e | 76 | .sp 1 |
3113c7f3 | 77 | .SH STANDARDS |
c5195941 | 78 | POSIX.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 | 82 | C89 only |
60a90ecd MK |
83 | includes the |
84 | .BR abs () | |
85 | and | |
86 | .BR labs () | |
87 | functions; the functions | |
88 | .BR llabs () | |
89 | and | |
90 | .BR imaxabs () | |
91 | were added in C99. | |
fea681da MK |
92 | .SH NOTES |
93 | Trying to take the absolute value of the most negative integer | |
94 | is not defined. | |
95 | .PP | |
60a90ecd MK |
96 | The |
97 | .BR llabs () | |
2de012be | 98 | function is included in glibc since version 2.0. |
60a90ecd MK |
99 | The |
100 | .BR imaxabs () | |
101 | function is included in | |
fea681da MK |
102 | glibc since version 2.1.1. |
103 | .PP | |
60a90ecd MK |
104 | For |
105 | .BR llabs () | |
106 | to be declared, it may be necessary to define | |
fea681da MK |
107 | \fB_ISOC99_SOURCE\fP or \fB_ISOC9X_SOURCE\fP (depending on the |
108 | version of glibc) before including any standard headers. | |
109 | .PP | |
63fe5027 | 110 | By default, |
60a90ecd | 111 | GCC handles |
36ad6ae0 MK |
112 | .BR abs (), |
113 | .BR labs (), | |
114 | and (since GCC 3.0) | |
60a90ecd MK |
115 | .BR llabs () |
116 | and | |
117 | .BR imaxabs () | |
36ad6ae0 | 118 | as 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) |