OSDN Git Service

(split) LDP_man-pages: release ioctl.2 [JM:00378]
[linuxjm/LDP_man-pages.git] / draft / man3 / strtod.3
1 .\" Copyright (c) 1990, 1991 The Regents of the University of California.
2 .\" All rights reserved.
3 .\"
4 .\" This code is derived from software contributed to Berkeley by
5 .\" the American National Standards Committee X3, on Information
6 .\" Processing Systems.
7 .\"
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
10 .\" are met:
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\"    notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\"    notice, this list of conditions and the following disclaimer in the
15 .\"    documentation and/or other materials provided with the distribution.
16 .\" 3. All advertising materials mentioning features or use of this software
17 .\"    must display the following acknowledgement:
18 .\"     This product includes software developed by the University of
19 .\"     California, Berkeley and its contributors.
20 .\" 4. Neither the name of the University nor the names of its contributors
21 .\"    may be used to endorse or promote products derived from this software
22 .\"    without specific prior written permission.
23 .\"
24 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 .\" SUCH DAMAGE.
35 .\"
36 .\"     @(#)strtod.3    5.3 (Berkeley) 6/29/91
37 .\"
38 .\" Modified Sun Aug 21 17:16:22 1994 by Rik Faith (faith@cs.unc.edu)
39 .\" Modified Sat May 04 19:34:31 MET DST 1996 by Michael Haardt
40 .\"   (michael@cantor.informatik.rwth-aachen.de)
41 .\" Added strof, strtold, aeb, 2001-06-07
42 .\"
43 .\" Japanese Version Copyright (c) 1998-1999
44 .\"   Michihide Hotta and NAKANO Takeo all rights reserved.
45 .\" Translated Fri Jun 26 1998 by Yasushi Shoji <yashi@yashi.com>
46 .\" Updated & Modified Sun Mar 14 1999 by NAKANO Takeo <nakano@apm.seikei.ac.jp>
47 .\" Updated & Modified Sun Jul  1 16:59:53 JST 2001
48 .\"         by Yuichi SATO <ysato@h4.dion.ne.jp>
49 .\" Updated & Modified 2006-07-20,
50 .\"         Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.36
51 .\"
52 .TH STRTOD 3 2010-00-20 "Linux" "Linux Programmer's Manual"
53 .\"O .SH NAME
54 .\"O strtod, strtof, strtold \- convert ASCII string to floating-point number
55 .SH Ì¾Á°
56 strtod, strtof, strtold \- ASCII Ê¸»úÎó¤òÉâÆ°¾®¿ôÅÀ¼Â¿ô¤ËÊÑ´¹¤¹¤ë
57 .\"O .SH SYNOPSIS
58 .SH ½ñ¼°
59 .B #include <stdlib.h>
60 .sp
61 .BI "double strtod(const char *" nptr ", char **" endptr );
62 .br
63 .BI "float strtof(const char *" nptr ", char **" endptr );
64 .br
65 .BI "long double strtold(const char *" nptr ", char **" endptr );
66 .sp
67 .in -4n
68 .\"O Feature Test Macro Requirements for glibc (see
69 .\"O .BR feature_test_macros (7)):
70 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
71 .RB ( feature_test_macros (7)
72 »²¾È):
73 .in
74 .ad l
75 .sp
76 .BR strtof (),
77 .BR strtold ():
78 .RS 4
79 _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE ||
80 _POSIX_C_SOURCE\ >=\ 200112L;
81 .br
82 or
83 .I cc\ -std=c99
84 .RE
85 .ad l
86 .\"O .SH DESCRIPTION
87 .SH ÀâÌÀ
88 .\"O The
89 .\"O .BR strtod (),
90 .\"O .BR strtof (),
91 .\"O and
92 .\"O .BR strtold ()
93 .\"O functions convert the initial portion of the string pointed to by
94 .\"O .I nptr
95 .\"O to
96 .\"O .IR double ,
97 .\"O .IR float ,
98 .\"O and
99 .\"O .I long double
100 .\"O representation, respectively.
101 .BR strtod (),
102 .BR strtof (),
103 .BR strtold ()
104 ´Ø¿ô¤Ï¡¢
105 .I nptr
106 ¤¬»Ø¤·¼¨¤¹Ê¸»úÎó¤Î¤Ï¤¸¤á¤ÎÉôʬ¤ò
107 .IR double ,
108 .IR float ,
109 .I long double
110 ·¿¤ÎÃͤˤ½¤ì¤¾¤ìÊÑ´¹¤¹¤ë¡£
111
112 .\"O The expected form of the (initial portion of the) string is
113 .\"O optional leading white space as recognized by
114 .\"O .BR isspace (3),
115 .\"O an optional plus (\(aq+\(aq) or minus sign (\(aq\-\(aq) and then either
116 .\"O (i) a decimal number, or (ii) a hexadecimal number,
117 .\"O or (iii) an infinity, or (iv) a NAN (not-a-number).
118 ÆþÎϤ¹¤ëʸ»úÎó (¤ÎÀèƬÉôʬ) ¤Ï°Ê²¼¤Î·Á¼°¤¬´üÂÔ¤µ¤ì¤Æ¤¤¤ë¡£
119 ÀèƬ¤Ë¥Û¥ï¥¤¥È¥¹¥Ú¡¼¥¹¡¢
120 ¼¡¤Ë¥×¥é¥¹ (\(aq+\(aq) ¤Þ¤¿¤Ï¥Þ¥¤¥Ê¥¹ (\(aq\-\(aq) ¤Îµ­¹æ¡¢
121 ¤½¤Î¸å¤Ë (i) 10 ¿Ê¿ô¡¢(ii) 16 ¿Ê¿ô¡¢(iii) Ìµ¸Â¡¢
122 (iv) NAN (·×»»¤Ç¤­¤Ê¤¤¿ô¡¢not-a-number) ¤Î¤¤¤º¤ì¤«¤¬¤¢¤ë
123 (¥Û¥ï¥¤¥È¥¹¥Ú¡¼¥¹¡¢Éä¹æ¤Ï¾Êά²Äǽ¡£
124 ¥Û¥ï¥¤¥È¥¹¥Ú¡¼¥¹¤Ï
125 .BR isspace (3)
126 ¤Ç¼±Ê̤µ¤ì¤ë)¡£
127 .LP
128 .\"O A
129 .\"O .I "decimal number"
130 .\"O consists of a nonempty sequence of decimal digits
131 .\"O possibly containing a radix character (decimal point, locale-dependent,
132 .\"O usually \(aq.\(aq), optionally followed by a decimal exponent.
133 .\"O A decimal exponent consists of an \(aqE\(aq or \(aqe\(aq, followed by an
134 .\"O optional plus or minus sign, followed by a nonempty sequence of
135 .\"O decimal digits, and indicates multiplication by a power of 10.
136 .I "10 ¿Ê¿ô"
137 ¤Ï 1 Ê¸»ú°Ê¾å¤Î 10 ¿Ê¤Î¿ô»ú¤ÎÎ󤫤é¤Ê¤ê¡¢
138 ´ð¤òɽ¤¹Ê¸»ú (radix charater)
139 (¾®¿ôÅÀ¡£¥í¥±¡¼¥ë¤Ë°Í¸¤¹¤ë¤¬¡¢Ä̾ï¤Ï \(aq.\(aq) ¤¬´Þ¤Þ¤ì¤ë¤³¤È¤â¤¢¤ë¡£
140 ¤³¤Î¸å¤Ë 10 ¿Ê¤Î»Ø¿ôÉô¤¬Â³¤¤¤Æ¤âÎɤ¤¡£
141 10 ¿Ê¤Î»Ø¿ôÉô¤Ï \(aqE\(aq ¤Þ¤¿¤Ï \(aqe\(aq ¤È¡¢¤½¤Î¸å¤ËÃÖ¤«¤ì¤ëÀµÉéµ­¹æ (¾Êά²Ä)¡¢
142 ¤ª¤è¤Ó¤½¤Î¸å¤Ë³¤¯ 1 Ê¸»ú°Ê¾å¤Î 10 ¿Ê¤Î¿ô»ú¤ÎÎ󤫤é¤Ê¤ê¡¢
143 10 ¤Î²¿¾è¤Ç¤¢¤ë¤«¤òɽ¤¹¡£
144 .LP
145 .\"O A
146 .\"O .I "hexadecimal number"
147 .\"O consists of a "0x" or "0X" followed by a nonempty sequence of
148 .\"O hexadecimal digits possibly containing a radix character,
149 .\"O optionally followed by a binary exponent.
150 .\"O A binary exponent
151 .\"O consists of a \(aqP\(aq or \(aqp\(aq, followed by an optional
152 .\"O plus or minus sign, followed by a nonempty sequence of
153 .\"O decimal digits, and indicates multiplication by a power of 2.
154 .\"O At least one of radix character and binary exponent must be present.
155 .I "16 ¿Ê¿ô"
156 ¤Ï¡¢"0x" ¤Þ¤¿¤Ï "0X" ¤È¤½¤Î¸å¤Ë³¤¯ 1 Ê¸»ú°Ê¾å¤Î 16 ¿Ê¤Î¿ô»ú¤ÎÎ󤫤é¤Ê¤ê¡¢
157 ´ð¤òɽ¤¹Ê¸»ú¤¬´Þ¤Þ¤ì¤ë¤³¤È¤â¤¢¤ë¡£
158 ¤³¤Î¸å¤Ë 2 ¿Ê¤Î»Ø¿ôÉô¤¬Â³¤¤¤Æ¤âÎɤ¤¡£
159 2 ¿Ê¤Î»Ø¿ôÉô¤Ï \(aqP\(aq ¤Þ¤¿¤Ï \(aqp\(aq ¤È¡¢¤½¤Î¸å¤ËÃÖ¤«¤ì¤ëÀµÉéµ­¹æ (¾Êά²Ä)¡¢
160 ¤ª¤è¤Ó¤½¤Î¸å¤Ë³¤¯ 1 Ê¸»ú°Ê¾å¤Î 10 ¿Ê¤Î¿ô»ú¤ÎÎ󤫤鹽À®¤µ¤ì¡¢
161 2 ¤Î²¿¾è¤Ç¤¢¤ë¤«¤òɽ¤¹¡£
162 ´ð¤òɽ¤¹Ê¸»ú¤È 2 ¿Ê¤Î»Ø¿ôÉô¤Ï¡¢¤É¤Á¤é¤«°ìÊý¤·¤«Â¸ºß¤·¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
163 .LP
164 .\"O An
165 .\"O .I infinity
166 .\"O is either "INF" or "INFINITY", disregarding case.
167 .I Ìµ¸Â
168 ¤Ï "INF" ¤Þ¤¿¤Ï "INFINITY" ¤Çɽ¤µ¤ì¡¢Âçʸ»ú¾®Ê¸»ú¤Ï¶èÊ̤µ¤ì¤Ê¤¤¡£
169 .LP
170 .\"O A
171 .\"O .I NAN
172 .\"O is "NAN" (disregarding case) optionally followed by \(aq(\(aq,
173 .\"O a sequence of characters, followed by \(aq)\(aq.
174 .\"O The character string specifies in an implementation-dependent
175 .\"O way the type of NAN.
176 .I NAN
177 ¤Ï "NAN" (Âçʸ»ú¾®Ê¸»ú¤Ï¶èÊ̤µ¤ì¤Ê¤¤) ¤Çɽ¤µ¤ì¡¢
178 ¤½¤Î¸å¤Ë \(aq(\(aq Ê¸»úÎó \(aq)\(aq ¤¬Â³¤¯¾ì¹ç¤â¤¢¤ë¡£
179 ¤³¤Îʸ»úÎó¤Ï¼ÂÁõ¤Ë°Í¸¤¹¤ë NAN ¤ò»ØÄꤹ¤ë¡£
180 .\" From glibc 2.8's stdlib/strtod_l.c:
181 .\"     We expect it to be a number which is put in the
182 .\"     mantissa of the number.
183 .\"O .SH "RETURN VALUES"
184 .SH ÊÖ¤êÃÍ
185 .\"O These functions return the converted value, if any.
186 ¤³¤ì¤é¤Î´Ø¿ô¤Ï¡¢ÊÑ´¹¤µ¤ì¤¿Ãͤ¬¤¢¤ì¤Ð¡¢¤½¤ì¤òÊÖ¤¹¡£
187
188 .\"O If
189 .\"O .I endptr
190 .\"O is not NULL,
191 .\"O a pointer to the character after the last character used in the conversion
192 .\"O is stored in the location referenced by
193 .\"O .IR endptr .
194 .I endptr
195 ¤¬ NULL ¤Ç¤Ê¤¤¤È¤­¤Ï¡¢ÊÑ´¹¤Ë»È¤ï¤ì¤¿ºÇ½ªÊ¸»ú¤Î¼¡¤Îʸ»ú¤Ø¤Î¥Ý¥¤¥ó¥¿¡¼¤¬
196 .I endptr
197 ¤Ç»²¾È¤µ¤ì¤ë¾ì½ê¤ØÊݸ¤µ¤ì¤ë¡£
198
199 .\"O If no conversion is performed, zero is returned and the value of
200 .\"O .I nptr
201 .\"O is stored in the location referenced by
202 .\"O .IR endptr .
203 ÊÑ´¹¤¬¹Ô¤ï¤ì¤Ê¤«¤Ã¤¿¤È¤­¤Ë¤Ï 0 ¤¬Ê֤롣¤½¤·¤Æ
204 .I endptr
205 ¤¬»²¾È¤·¤Æ¤¤¤ë¾ì½ê¤Ë
206 .I nptr
207 ¤ÎÃÍ (ÊÑ´¹ÂоݤǤ¢¤ëʸ»úÎó¤Î³«»Ï¥¢¥É¥ì¥¹) ¤¬Êݸ¤µ¤ì¤ë¡£
208
209 .\"O If the correct value would cause overflow, plus or minus
210 .\"O .B HUGE_VAL
211 .\"O .RB ( HUGE_VALF ,
212 .\"O .BR HUGE_VALL )
213 .\"O is returned (according to the sign of the value), and
214 .\"O .B ERANGE
215 .\"O is stored in
216 .\"O .IR errno .
217 .\"O If the correct value would cause underflow, zero is
218 .\"O returned and
219 .\"O .B ERANGE
220 .\"O is stored in
221 .\"O .IR errno .
222 Àµ¤·¤¤·Á¼°¤Î¿ôÃÍʸ»úÎó¤Ç¤¢¤ë¤¬¡¢ÊÑ´¹·ë²Ì¤¬¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¤òµ¯¤³¤·¤¿¾ì¹ç
223 ¤Ë¤Ï¡¢¥×¥é¥¹¤Þ¤¿¤Ï¥Þ¥¤¥Ê¥¹¤Î
224 .B HUGE_VAL
225 .RB ( HUGE_VALF ,
226 .BR HUGE_VALL )
227 ¤¬ÊÖ¤ê (ÃͤÎÉä¹æ¤Ë¤è¤ë)¡¢
228 .B ERANGE
229 ¤¬
230 .I errno
231 ¤ËÂåÆþ¤µ¤ì¤ë¡£ÊÑ´¹·ë²Ì¤¬¥¢¥ó¥À¡¼¥Õ¥í¡¼¤òµ¯¤³¤·¤¿¾ì¹ç¤Ë¤Ï 0 ¤¬Ê֤ꡢ
232 .B ERANGE
233 ¤¬
234 .I errno
235 ¤ËÂåÆþ¤µ¤ì¤ë¡£
236 .\"O .SH ERRORS
237 .SH ¥¨¥é¡¼
238 .TP
239 .B ERANGE
240 .\"O Overflow or underflow occurred.
241 ¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¤Þ¤¿¤Ï¥¢¥ó¥À¡¼¥Õ¥í¡¼¤¬µ¯¤³¤Ã¤¿¡£
242 .\"O .SH "CONFORMING TO"
243 .SH ½àµò
244 .\"O C89 describes
245 .\"O .BR strtod (),
246 .\"O C99
247 .\"O describes the other two functions.
248 C89 ¤Ç¤Ï
249 .BR strtod ()
250 ¤¬¡¢C99 ¤Ç¤Ï»Ä¤ê¤Î 2 ¤Ä¤Î´Ø¿ô¤¬µ­½Ò¤µ¤ì¤Æ¤¤¤ë¡£
251 .\"O .SH NOTES
252 .SH Ãí°Õ
253 .\"O Since
254 .\"O 0 can legitimately be returned
255 .\"O on both success and failure, the calling program should set
256 .\"O .I errno
257 .\"O to 0 before the call,
258 .\"O and then determine if an error occurred by checking whether
259 .\"O .I errno
260 .\"O has a nonzero value after the call.
261 À®¸ù¡¢¼ºÇԤɤÁ¤é¤Î¾ì¹ç¤Ç¤â 0 ¤òÊÖ¤¹²ÄǽÀ­¤¬¤¢¤ë¤Î¤Ç¡¢
262 ¥×¥í¥°¥é¥à¤Ï¸Æ¤Ó½Ð¤¹Á°¤Ë
263 .I errno
264 ¤ò 0 ¤ËÀßÄꤷ¡¢¸Æ¤Ó½Ð¤·¸å¤Ë
265 .I errno
266 ¤¬ 0 °Ê³°¤ÎÃͤ«¤É¤¦¤«¤ò³Îǧ¤·¥¨¥é¡¼¤¬È¯À¸¤·¤¿¤«¤É¤¦¤«¤òȽÃǤ¹¤ë
267 ɬÍפ¬¤¢¤ë¡£
268 .\"O .SH EXAMPLE
269 .SH Îã
270 .\"O See the example on the
271 .\"O .BR strtol (3)
272 .\"O manual page;
273 .\"O the use of the functions described in this manual page is similar.
274 .BR strtol (3)
275 ¤Î¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¤ÎÎã¤ò»²¾È¡£
276 ¤³¤Î¥Ú¡¼¥¸¤ÇÀâÌÀ¤·¤¿´Ø¿ô¤Î»ÈÍÑÊýË¡¤âƱÍͤǤ¢¤ë¡£
277 .\"O .SH "SEE ALSO"
278 .SH ´ØÏ¢¹àÌÜ
279 .BR atof (3),
280 .BR atoi (3),
281 .BR atol (3),
282 .BR strtol (3),
283 .BR strtoul (3)