OSDN Git Service

b1819c95d6bbcac3260dad67a24f870ccdc2958b
[linuxjm/LDP_man-pages.git] / draft / 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 .\" Japanese Version Copyright (c) 1996 Kentaro OGAWA
33 .\"         all rights reserved.
34 .\" Translated Sat, 13 Jul 1996 22:44:04 +0900
35 .\"         by Kentaro OGAWA <k_ogawa@oyna.cc.muroran-it.ac.jp>
36 .\" Updated Mon 29 Jan 2001 17:18:34 JST by Kentaro Shirakata <argrath@ub32.org>
37 .\"
38 .TH ABS 3  2010-09-20 "GNU" "Linux Programmer's Manual"
39 .SH Ì¾Á°
40 .\"O abs, labs, llabs, imaxabs \- compute the absolute value of an integer
41 abs, labs, llabs, imaxabs \- À°¿ô¤ÎÀäÂÐÃͤò·×»»¤¹¤ë
42 .SH ½ñ¼°
43 .nf
44 .B #include <stdlib.h>
45 .sp
46 .BI "int abs(int " j );
47 .br
48 .BI "long int labs(long int " j );
49 .br
50 .BI "long long int llabs(long long int " j );
51 .sp
52 .B #include <inttypes.h>
53 .sp
54 .BI "intmax_t imaxabs(intmax_t " j );
55 .fi
56 .sp
57 .in -4n
58 .\"O Feature Test Macro Requirements for glibc (see
59 .\"O .BR feature_test_macros (7)):
60 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
61 .RB ( feature_test_macros (7)
62 »²¾È):
63 .in
64 .sp
65 .ad l
66 .BR llabs ():
67 .RS 4
68 _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE ||
69 _POSIX_C_SOURCE\ >=\ 200112L;
70 .br
71 or
72 .I cc\ -std=c99
73 .ad
74 .SH ÀâÌÀ
75 .\"O The
76 .\"O .BR abs ()
77 .\"O function computes the absolute value of the integer
78 .\"O argument \fIj\fP.
79 .\"O The
80 .\"O .BR labs (),
81 .\"O .BR llabs ()
82 .\"O and
83 .\"O .BR imaxabs ()
84 .\"O functions compute the absolute value of the argument \fIj\fP of the
85 .\"O appropriate integer type for the function.
86 .BR abs ()
87 ´Ø¿ô¤Ï¡¢À°¿ô¤Î°ú¿ô \fIj\fP ¤ÎÀäÂÐÃͤò·×»»¤¹¤ë¡£
88 .BR labs (),
89 .BR llabs (),
90 .BR imaxabs ()
91 ´Ø¿ô¤Ï¡¢
92 ¤½¤ì¤¾¤ì¤Î´Ø¿ô¤Î·¿¤Ë±þ¤¸¤¿°ú¿ô \fIj\fP ¤ÎÀäÂÐÃͤò·×»»¤¹¤ë¡£
93 .SH ÊÖ¤êÃÍ
94 .\"O Returns the absolute value of the integer argument, of the appropriate
95 .\"O integer type for the function.
96 ¤½¤ì¤¾¤ì¤Î´Ø¿ô¤Î·¿¤Ë±þ¤¸¤¿À°¿ô¤Î°ú¿ô¤ÎÀäÂÐÃͤòÊÖ¤¹¡£
97 .SH ½àµò
98 .\"O SVr4, POSIX.1-2001, 4.3BSD, C99.
99 .\"O .\" POSIX.1 (1996 edition) only requires the
100 .\"O .\" .BR abs ()
101 .\"O .\" function.
102 .\"O C89 only
103 .\"O includes the
104 .\"O .BR abs ()
105 .\"O and
106 .\"O .BR labs ()
107 .\"O functions; the functions
108 .\"O .BR llabs ()
109 .\"O and
110 .\"O .BR imaxabs ()
111 .\"O were added in C99.
112 SVr4, POSIX.1-2001, 4.3BSD, C99.
113 .\" POSIX.1 (1996 Ç¯ÈÇ) ¤Ï
114 .\" .BR abs ()
115 .\" ´Ø¿ô¤Î¤ß¤òÍ׵ᤷ¤Æ¤¤¤ë¡£
116 C89 ¤Ï
117 .BR abs ()
118 ´Ø¿ô¤È
119 .BR labs ()
120 ´Ø¿ô¤Î¤ß¤ò´Þ¤ó¤Ç¤¤¤ë¡£
121 .BR llabs ()
122 ´Ø¿ô¤È
123 .BR imaxabs ()
124 ´Ø¿ô¤Ï C99 ¤ÇÄɲ䵤줿¡£
125 .SH Ãí°Õ
126 .\"O Trying to take the absolute value of the most negative integer
127 .\"O is not defined.
128 ºÇÂç¤ÎÉéÀ°¿ô¤ÎÀäÂÐÃͤϡ¢ÄêµÁ¤µ¤ì¤Æ¤¤¤Ê¤¤¡£
129 .PP
130 .\"O The
131 .\"O .BR llabs ()
132 .\"O function is included in glibc since version 2.0, but
133 .\"O is not in libc5 or libc4.
134 .\"O The
135 .\"O .BR imaxabs ()
136 .\"O function is included in
137 .\"O glibc since version 2.1.1.
138 .BR llabs ()
139 ´Ø¿ô¤Ï¥Ð¡¼¥¸¥ç¥ó 2.0 ¤«¤é glibc ¤Ë´Þ¤Þ¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¤¬¡¢
140 libc5 ¤ä libc4 ¤Ë¤Ï¤Ê¤¤¡£
141 .BR imaxabs ()
142 ´Ø¿ô¤Ï ¥Ð¡¼¥¸¥ç¥ó 2.1.1 ¤«¤é glibc ¤Ë´Þ¤Þ¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£
143 .PP
144 .\"O For
145 .\"O .BR llabs ()
146 .\"O to be declared, it may be necessary to define
147 .\"O \fB_ISOC99_SOURCE\fP or \fB_ISOC9X_SOURCE\fP (depending on the
148 .\"O version of glibc) before including any standard headers.
149 .BR llabs ()
150 ¤¬Àë¸À¤µ¤ì¤ë¤¿¤á¤Ë¤Ï¡¢É¸½à¥Ø¥Ã¥À¤ò include ¤¹¤ëÁ°¤Ë
151 \fB_ISOC99_SOURCE\fP ¤« \fB_ISOC9X_SOURCE\fP(¤É¤Á¤é¤«¤Ï glibc ¤Î
152 ¥Ð¡¼¥¸¥ç¥ó¤Ë°Í¸¤¹¤ë)¤ò define ¤·¤Æ¤ª¤¯É¬Íפ¬¤¢¤ë¡£
153 .PP
154 .\"O GCC handles
155 .\"O .BR abs ()
156 .\"O and
157 .\"O .BR labs ()
158 .\"O as builtin functions.
159 .\"O GCC 3.0 also handles
160 .\"O .BR llabs ()
161 .\"O and
162 .\"O .BR imaxabs ()
163 .\"O as builtins.
164 GCC ¤Ï
165 .BR abs ()
166 ¤È
167 .BR labs ()
168 ¤ò¥Ó¥ë¥É¥¤¥ó´Ø¿ô¤È¤·¤Æ°·¤¦¡£
169 GCC 3.0 ¤Ï
170 .BR llabs ()
171 ¤È
172 .BR imaxabs ()
173 ¤â¥Ó¥ë¥É¥¤¥ó¤È¤·¤Æ°·¤¦¡£
174 .SH ´ØÏ¢¹àÌÜ
175 .BR cabs (3),
176 .BR ceil (3),
177 .BR fabs (3),
178 .BR floor (3),
179 .BR rint (3)