OSDN Git Service

(split) Import translated manuals from JM CVS Repository.
[linuxjm/LDP_man-pages.git] / original / man3 / abs.3
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.
11 .\"
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.
19 .\"
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  2007-07-26 "GNU" "Linux Programmer's Manual"
33 .SH NAME
34 abs, 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 .sp
50 .in -4n
51 Feature Test Macro Requirements for glibc (see
52 .BR feature_test_macros (7)):
53 .in
54 .sp
55 .BR llabs ():
56 _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE; or
57 .I cc\ -std=c99
58 .SH DESCRIPTION
59 The
60 .BR abs ()
61 function computes the absolute value of the integer
62 argument \fIj\fP.
63 The
64 .BR labs (),
65 .BR llabs ()
66 and
67 .BR imaxabs ()
68 functions compute the absolute value of the argument \fIj\fP of the
69 appropriate integer type for the function.
70 .SH "RETURN VALUE"
71 Returns the absolute value of the integer argument, of the appropriate
72 integer type for the function.
73 .SH "CONFORMING TO"
74 SVr4, POSIX.1-2001, 4.3BSD, C99.
75 .\" POSIX.1 (1996 edition) only requires the
76 .\" .BR abs ()
77 .\" function.
78 C89 only
79 includes the
80 .BR abs ()
81 and
82 .BR labs ()
83 functions; the functions
84 .BR llabs ()
85 and
86 .BR imaxabs ()
87 were added in C99.
88 .SH NOTES
89 Trying to take the absolute value of the most negative integer
90 is not defined.
91 .PP
92 The
93 .BR llabs ()
94 function is included in glibc since version 2.0, but
95 is not in libc5 or libc4.
96 The
97 .BR imaxabs ()
98 function is included in
99 glibc since version 2.1.1.
100 .PP
101 For
102 .BR llabs ()
103 to be declared, it may be necessary to define
104 \fB_ISOC99_SOURCE\fP or \fB_ISOC9X_SOURCE\fP (depending on the
105 version of glibc) before including any standard headers.
106 .PP
107 GCC handles
108 .BR abs ()
109 and
110 .BR labs ()
111 as built-in functions.
112 GCC 3.0 also handles
113 .BR llabs ()
114 and
115 .BR imaxabs ()
116 as built-ins.
117 .SH "SEE ALSO"
118 .BR cabs (3),
119 .BR ceil (3),
120 .BR fabs (3),
121 .BR floor (3),
122 .BR rint (3)