OSDN Git Service

Convert release and draft pages to UTF-8.
[linuxjm/jm.git] / manual / LDP_man-pages / draft / man3 / strtoul.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 Sun Jul 25 10:54:03 1993 by Rik Faith (faith@cs.unc.edu)
28 .\" Fixed typo, aeb, 950823
29 .\" 2002-02-22, joey, mihtjel: Added strtoull()
30 .\"
31 .\" Japanese Version Copyright (c) 1999 AKAMATSU, Kazuo
32 .\"                            and 2006 Akihiro MOTOKI
33 .\"         all rights reserved.
34 .\" Translated Thu Jan 31 18:00:00 JST 1999
35 .\"         by AKAMATSU, Kazuo
36 .\" Updated & Modified 2006-07-20,
37 .\"         Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.36
38 .\"
39 .\" WORD:       base            基数
40 .\"
41 .TH STRTOUL 3  2011-09-15 "GNU" "Linux Programmer's Manual"
42 .SH 名前
43 .\"O strtoul, strtoull, strtouq \- convert a string to an unsigned long integer
44 strtoul, strtoull, strtouq \- 文字列を unsigned long int に変換する
45 .SH 書式
46 .nf
47 .B #include <stdlib.h>
48 .sp
49 .BI "unsigned long int strtoul(const char *" nptr ", char **" endptr \
50 ", int " base );
51 .sp
52 .BI "unsigned long long int strtoull(const char *" nptr ", char **" endptr ,
53 .BI "                                int " base );
54 .fi
55 .sp
56 .in -4n
57 .\"O Feature Test Macro Requirements for glibc (see
58 .\"O .BR feature_test_macros (7)):
59 glibc 向けの機能検査マクロの要件
60 .RB ( feature_test_macros (7)
61 参照):
62 .in
63 .sp
64 .ad l
65 .BR strtoull ():
66 .RS 4
67 XOPEN_SOURCE\ >=\ 600 || _BSD_SOURCE || _SVID_SOURCE || _ISOC99_SOURCE ||
68 _POSIX_C_SOURCE\ >=\ 200112L;
69 .br
70 or
71 .I cc\ -std=c99
72 .RE
73 .ad
74 .SH 説明
75 .\"O The
76 .\"O .BR strtoul ()
77 .\"O function converts the initial part of the string
78 .\"O in \fInptr\fP to an
79 .\"O .I "unsigned long int"
80 .\"O value according to the
81 .\"O given \fIbase\fP, which must be between 2 and 36 inclusive, or be
82 .\"O the special value 0.
83 .BR strtoul ()
84 関数は、 \fInptr\fP の文字列の最初の部分を、
85 \fIbase\fP を基数として
86 .I "unsigned long int"
87 に変換する。
88 この \fIbase\fP は 2 から 36 までの値
89 あるいは特別な意味を持つ値 0 でなければならない。
90 .PP
91 .\"O The string may begin with an arbitrary amount of white space (as
92 .\"O determined by
93 .\"O .BR isspace (3))
94 .\"O followed by a single optional \(aq+\(aq or \(aq\-\(aq
95 .\"O sign.
96 .\"O If \fIbase\fP is zero or 16, the string may then include a
97 .\"O "0x" prefix, and the number will be read in base 16; otherwise, a
98 .\"O zero \fIbase\fP is taken as 10 (decimal) unless the next character
99 .\"O is \(aq0\(aq, in which case it is taken as 8 (octal).
100 文字列の先頭には、任意の数の空白があってもよく (空白は
101 .BR ( isspace (3)
102 で判定される) 、また数字の直前には \(aq+\(aq か \(aq\-\(aq の
103 符号があってもよい。
104 \fIbase\fP が 0 または 16 の場合には、 文字列の先頭に "0x" を置くことが
105 でき、その場合には文字列は 16進数として扱われる。
106 これ以外の文字列で \fIbase\fP が 0 の場合は、
107 文字列が \(aq0\(aq で始まるときは 8進数として、
108 それ以外のときは 10進数として扱われる。
109 .PP
110 .\"O The remainder of the string is converted to an
111 .\"O .I "unsigned long int"
112 .\"O value in the obvious manner,
113 .\"O stopping at the first character which is not a
114 .\"O valid digit in the given base.
115 .\"O (In bases above 10, the letter \(aqA\(aq in
116 .\"O either upper or lower case represents 10, \(aqB\(aq represents 11, and so
117 .\"O forth, with \(aqZ\(aq representing 35.)
118 文字列の残りの部分は
119 .I "unsigned long int"
120 に変換されるが、基数に対して
121 有効でない数字が現れた時点で変換は終了する。(11進数以上では \(aqA\(aq は
122 大文字・小文字に関わらず 10 を表し、 \(aqB\(aq は 11 を表現し,
123 以下同様に、 \(aqZ\(aq は 35 を表す。)
124 .PP
125 .\"O If \fIendptr\fP is not NULL,
126 .\"O .BR strtoul ()
127 .\"O stores the address of the
128 .\"O first invalid character in \fI*endptr\fP.
129 .\"O If there were no digits at
130 .\"O all,
131 .\"O .BR strtoul ()
132 .\"O stores the original value of \fInptr\fP in
133 .\"O \fI*endptr\fP (and returns 0).
134 .\"O In particular, if \fI*nptr\fP is not \(aq\\0\(aq but \fI**endptr\fP
135 .\"O is \(aq\\0\(aq on return, the entire string is valid.
136 \fIendptr\fP がヌル値 (NULL) でない場合、
137 .BR strtoul ()
138 は最初に不正な文字が現れたアドレスを
139 \fI*endptr\fP に格納している。
140 文字列に有効な数字がひとつもなければ、
141 .BR strtoul ()
142 は \fInptr\fP
143 の元の値を \fI*endptr\fP に代入する(そして 0 を返す)。
144 特に、 \fI*nptr\fP が \(aq\\0\(aq 以外で、返された \fI**endptr\fP が
145 \(aq\\0\(aq ならば、文字列全体が有効だったことになる。
146 .PP
147 .\"O The
148 .\"O .BR strtoull ()
149 .\"O function works just like the
150 .\"O .BR strtoul ()
151 .\"O function but returns an
152 .\"O .I "unsigned long long int"
153 .\"O value.
154 .BR strtoull ()
155 関数は
156 .BR strtoul ()
157 関数と同様だが、
158 .I "unsigned long long int"
159 型の値を返す。
160 .SH 返り値
161 .\"O The
162 .\"O .BR strtoul ()
163 .\"O function returns either the result of the conversion
164 .\"O or, if there was a leading minus sign, the negation of the result of the
165 .\"O conversion represented as an unsigned value,
166 .\"O unless the original (nonnegated) value would overflow; in
167 .\"O the latter case,
168 .\"O .BR strtoul ()
169 .\"O returns
170 .\"O .B ULONG_MAX
171 .\"O and sets \fIerrno\fP to
172 .\"O .BR ERANGE .
173 .BR strtoul ()
174 関数は変換結果を返す。文字列がマイナス符号から始まっていた場
175 合は、(符号反転前の値がオーバーフローしていなければ) 変換結果を符号反転した
176 値を unsigned 型で返す。変換でオーバーフローが発生した場合は
177 .B ULONG_MAX
178 を返し、
179 .I errno
180
181 .B ERANGE
182 を設定する。
183 .\"O Precisely the same holds for
184 .\"O .BR strtoull ()
185 .\"O (with
186 .\"O .B ULLONG_MAX
187 .\"O instead of
188 .\"O .BR ULONG_MAX ).
189 .RB ( ULONG_MAX
190
191 .B ULLONG_MAX
192 と読み替えれば)
193 .BR strtoull ()
194
195 .BR strtoul ()
196 と全く同じである。
197 .SH エラー
198 .TP
199 .B EINVAL
200 .\"O (not in C99)
201 .\"O The given
202 .\"O .I base
203 .\"O contains an unsupported value.
204 (C99 にはない)
205 与えられた
206 .I base
207 がサポートされていない値である。
208 .TP
209 .B ERANGE
210 .\"O The resulting value was out of range.
211 文字列が数値の表現範囲外である。
212 .LP
213 .\"O The implementation may also set \fIerrno\fP to \fBEINVAL\fP in case
214 .\"O no conversion was performed (no digits seen, and 0 returned).
215 実装によっては、全く変換が行われなかった場合(全く数字が現れず、
216 0 が返される)、\fIerrno\fP に \fBEINVAL\fP がセットされるかもしれない。
217 .\"O .SH "CONFORMING TO"
218 .SH 準拠
219 .\"O .BR strtoul ()
220 .\"O conforms to SVr4, C89, C99 and POSIX-2001, and
221 .\"O .BR strtoull ()
222 .\"O to C99 and POSIX.1-2001.
223 .BR strtoul ()
224 は SVr4, C89, C99 と POSIX-2001 に準拠している。
225 .BR strtoull ()
226 は C99 と POSIX.1-2001 に準拠している。
227 .\"O .SH NOTES
228 .SH 注意
229 .\"O Since
230 .\"O .BR strtoul ()
231 .\"O can legitimately return 0 or
232 .\"O .B ULONG_MAX
233 .\"O .RB ( ULLONG_MAX
234 .\"O for
235 .\"O .BR strtoull ())
236 .\"O on both success and failure, the calling program should set
237 .\"O .I errno
238 .\"O to 0 before the call,
239 .\"O and then determine if an error occurred by checking whether
240 .\"O .I errno
241 .\"O has a nonzero value after the call.
242 .B strtoul ()
243 からは成功、失敗どちらの場合でも 0 や
244 .B ULONG_MAX
245 .RB ( strtoull ()
246 では
247 .BR ULLONG_MAX )
248 が返る可能性があるので、
249 プログラムは関数を呼び出す前に
250 .I errno
251 を 0 に設定し、呼び出し後に
252 .I errno
253 が 0 以外の値かどうかを確認しエラーが発生したかどうかを判断する
254 必要がある。
255
256 .\"O In locales other than the "C" locale, other strings may be accepted.
257 "C" 以外のロケールの場合、その他の文字列も受け付けられるかもしれない。
258 .\"O (For example, the thousands separator of the current locale may be
259 .\"O supported.)
260 (例えば、現在のロケールの 1000 毎の区切り文字に対応しているかもしれない。)
261 .LP
262 .\"O BSD also has
263 BSD には、
264 .sp
265 .in +4n
266 .nf
267 .BI "u_quad_t strtouq(const char *" nptr ", char **" endptr ", int " base );
268 .sp
269 .in -4n
270 .fi
271 .\"O with completely analogous definition.
272 という完全に同様の定義を持つ関数がある。
273 .\"O Depending on the wordsize of the current architecture, this
274 .\"O may be equivalent to
275 .\"O .BR strtoull ()
276 .\"O or to
277 .\"O .BR strtoul ().
278 使用中のアーキテクチャのワード長次第であるが、この関数は
279 .BR strtoull ()
280
281 .BR stroul ()
282 と等価な場合もありえる。
283
284 .\"O Negative values are considered valid input and are
285 .\"O silently converted to the equivalent
286 .\"O .I "unsigned long int"
287 .\"O value.
288 負の値も正当な入力とみなされ、エラーもなく、
289 対応する
290 .I "unsigned long int"
291 型の値に変換される。
292 .\"O .SH EXAMPLE
293 .SH 例
294 .\"O See the example on the
295 .\"O .BR strtol (3)
296 .\"O manual page;
297 .\"O the use of the functions described in this manual page is similar.
298 .BR strtol (3)
299 のマニュアルページの例を参照。
300 このページで説明した関数の使用方法も同様である。
301 .\"O .SH "SEE ALSO"
302 .SH 関連項目
303 .BR atof (3),
304 .BR atoi (3),
305 .BR atol (3),
306 .BR strtod (3),
307 .BR strtol (3)