1 .\" Copyright (c) 1990, 1991 The Regents of the University of California.
2 .\" All rights reserved.
4 .\" This code is derived from software contributed to Berkeley by
5 .\" the American National Standards Committee X3, on Information
6 .\" Processing Systems.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
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.
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
36 .\" @(#)strtod.3 5.3 (Berkeley) 6/29/91
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
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
52 .TH STRTOD 3 2010-00-20 "Linux" "Linux Programmer's Manual"
54 .\"O strtod, strtof, strtold \- convert ASCII string to floating-point number
56 strtod, strtof, strtold \- ASCII ʸ»úÎó¤òÉâÆ°¾®¿ôÅÀ¼Â¿ô¤ËÊÑ´¹¤¹¤ë
59 .B #include <stdlib.h>
61 .BI "double strtod(const char *" nptr ", char **" endptr );
63 .BI "float strtof(const char *" nptr ", char **" endptr );
65 .BI "long double strtold(const char *" nptr ", char **" endptr );
68 .\"O Feature Test Macro Requirements for glibc (see
69 .\"O .BR feature_test_macros (7)):
70 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
71 .RB ( feature_test_macros (7)
79 _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE ||
80 _POSIX_C_SOURCE\ >=\ 200112L;
93 .\"O functions convert the initial portion of the string pointed to by
100 .\"O representation, respectively.
106 ¤¬»Ø¤·¼¨¤¹Ê¸»úÎó¤Î¤Ï¤¸¤á¤ÎÉôʬ¤ò
110 ·¿¤ÎÃͤˤ½¤ì¤¾¤ìÊÑ´¹¤¹¤ë¡£
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 (¥Û¥ï¥¤¥È¥¹¥Ú¡¼¥¹¡¢Éä¹æ¤Ï¾Êά²Äǽ¡£
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.
137 ¤Ï 1 ʸ»ú°Ê¾å¤Î 10 ¿Ê¤Î¿ô»ú¤ÎÎ󤫤é¤Ê¤ê¡¢
138 ´ð¤òɽ¤¹Ê¸»ú (radix charater)
139 (¾®¿ôÅÀ¡£¥í¥±¡¼¥ë¤Ë°Í¸¤¹¤ë¤¬¡¢Ä̾ï¤Ï \(aq.\(aq) ¤¬´Þ¤Þ¤ì¤ë¤³¤È¤â¤¢¤ë¡£
140 ¤³¤Î¸å¤Ë 10 ¿Ê¤Î»Ø¿ôÉô¤¬Â³¤¤¤Æ¤âÎɤ¤¡£
141 10 ¿Ê¤Î»Ø¿ôÉô¤Ï \(aqE\(aq ¤Þ¤¿¤Ï \(aqe\(aq ¤È¡¢¤½¤Î¸å¤ËÃÖ¤«¤ì¤ëÀµÉéµ¹æ (¾Êά²Ä)¡¢
142 ¤ª¤è¤Ó¤½¤Î¸å¤Ë³¤¯ 1 ʸ»ú°Ê¾å¤Î 10 ¿Ê¤Î¿ô»ú¤ÎÎ󤫤é¤Ê¤ê¡¢
143 10 ¤Î²¿¾è¤Ç¤¢¤ë¤«¤òɽ¤¹¡£
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.
156 ¤Ï¡¢"0x" ¤Þ¤¿¤Ï "0X" ¤È¤½¤Î¸å¤Ë³¤¯ 1 ʸ»ú°Ê¾å¤Î 16 ¿Ê¤Î¿ô»ú¤ÎÎ󤫤é¤Ê¤ê¡¢
157 ´ð¤òɽ¤¹Ê¸»ú¤¬´Þ¤Þ¤ì¤ë¤³¤È¤â¤¢¤ë¡£
158 ¤³¤Î¸å¤Ë 2 ¿Ê¤Î»Ø¿ôÉô¤¬Â³¤¤¤Æ¤âÎɤ¤¡£
159 2 ¿Ê¤Î»Ø¿ôÉô¤Ï \(aqP\(aq ¤Þ¤¿¤Ï \(aqp\(aq ¤È¡¢¤½¤Î¸å¤ËÃÖ¤«¤ì¤ëÀµÉéµ¹æ (¾Êά²Ä)¡¢
160 ¤ª¤è¤Ó¤½¤Î¸å¤Ë³¤¯ 1 ʸ»ú°Ê¾å¤Î 10 ¿Ê¤Î¿ô»ú¤ÎÎ󤫤鹽À®¤µ¤ì¡¢
161 2 ¤Î²¿¾è¤Ç¤¢¤ë¤«¤òɽ¤¹¡£
162 ´ð¤òɽ¤¹Ê¸»ú¤È 2 ¿Ê¤Î»Ø¿ôÉô¤Ï¡¢¤É¤Á¤é¤«°ìÊý¤·¤«Â¸ºß¤·¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
166 .\"O is either "INF" or "INFINITY", disregarding case.
168 ¤Ï "INF" ¤Þ¤¿¤Ï "INFINITY" ¤Çɽ¤µ¤ì¡¢Âçʸ»ú¾®Ê¸»ú¤Ï¶èÊ̤µ¤ì¤Ê¤¤¡£
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.
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"
185 .\"O These functions return the converted value, if any.
186 ¤³¤ì¤é¤Î´Ø¿ô¤Ï¡¢ÊÑ´¹¤µ¤ì¤¿Ãͤ¬¤¢¤ì¤Ð¡¢¤½¤ì¤òÊÖ¤¹¡£
191 .\"O a pointer to the character after the last character used in the conversion
192 .\"O is stored in the location referenced by
195 ¤¬ NULL ¤Ç¤Ê¤¤¤È¤¤Ï¡¢ÊÑ´¹¤Ë»È¤ï¤ì¤¿ºÇ½ªÊ¸»ú¤Î¼¡¤Îʸ»ú¤Ø¤Î¥Ý¥¤¥ó¥¿¡¼¤¬
197 ¤Ç»²¾È¤µ¤ì¤ë¾ì½ê¤ØÊݸ¤µ¤ì¤ë¡£
199 .\"O If no conversion is performed, zero is returned and the value of
201 .\"O is stored in the location referenced by
203 ÊÑ´¹¤¬¹Ô¤ï¤ì¤Ê¤«¤Ã¤¿¤È¤¤Ë¤Ï 0 ¤¬Ê֤롣¤½¤·¤Æ
207 ¤ÎÃÍ (ÊÑ´¹ÂоݤǤ¢¤ëʸ»úÎó¤Î³«»Ï¥¢¥É¥ì¥¹) ¤¬Êݸ¤µ¤ì¤ë¡£
209 .\"O If the correct value would cause overflow, plus or minus
211 .\"O .RB ( HUGE_VALF ,
213 .\"O is returned (according to the sign of the value), and
217 .\"O If the correct value would cause underflow, zero is
222 Àµ¤·¤¤·Á¼°¤Î¿ôÃÍʸ»úÎó¤Ç¤¢¤ë¤¬¡¢ÊÑ´¹·ë²Ì¤¬¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¤òµ¯¤³¤·¤¿¾ì¹ç
223 ¤Ë¤Ï¡¢¥×¥é¥¹¤Þ¤¿¤Ï¥Þ¥¤¥Ê¥¹¤Î
227 ¤¬ÊÖ¤ê (ÃͤÎÉä¹æ¤Ë¤è¤ë)¡¢
231 ¤ËÂåÆþ¤µ¤ì¤ë¡£ÊÑ´¹·ë²Ì¤¬¥¢¥ó¥À¡¼¥Õ¥í¡¼¤òµ¯¤³¤·¤¿¾ì¹ç¤Ë¤Ï 0 ¤¬Ê֤ꡢ
240 .\"O Overflow or underflow occurred.
241 ¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¤Þ¤¿¤Ï¥¢¥ó¥À¡¼¥Õ¥í¡¼¤¬µ¯¤³¤Ã¤¿¡£
242 .\"O .SH "CONFORMING TO"
247 .\"O describes the other two functions.
250 ¤¬¡¢C99 ¤Ç¤Ï»Ä¤ê¤Î 2 ¤Ä¤Î´Ø¿ô¤¬µ½Ò¤µ¤ì¤Æ¤¤¤ë¡£
254 .\"O 0 can legitimately be returned
255 .\"O on both success and failure, the calling program should set
257 .\"O to 0 before the call,
258 .\"O and then determine if an error occurred by checking whether
260 .\"O has a nonzero value after the call.
261 À®¸ù¡¢¼ºÇԤɤÁ¤é¤Î¾ì¹ç¤Ç¤â 0 ¤òÊÖ¤¹²ÄǽÀ¤¬¤¢¤ë¤Î¤Ç¡¢
262 ¥×¥í¥°¥é¥à¤Ï¸Æ¤Ó½Ð¤¹Á°¤Ë
264 ¤ò 0 ¤ËÀßÄꤷ¡¢¸Æ¤Ó½Ð¤·¸å¤Ë
266 ¤¬ 0 °Ê³°¤ÎÃͤ«¤É¤¦¤«¤ò³Îǧ¤·¥¨¥é¡¼¤¬È¯À¸¤·¤¿¤«¤É¤¦¤«¤òȽÃǤ¹¤ë
270 .\"O See the example on the
273 .\"O the use of the functions described in this manual page is similar.
275 ¤Î¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¤ÎÎã¤ò»²¾È¡£
276 ¤³¤Î¥Ú¡¼¥¸¤ÇÀâÌÀ¤·¤¿´Ø¿ô¤Î»ÈÍÑÊýË¡¤âƱÍͤǤ¢¤ë¡£