2 .\" Copyright (c) 1992, X/Open Company Limited All Rights Reserved Portions Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved
3 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
4 .\" http://www.opengroup.org/bookstore/.
5 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
6 .\" This notice shall appear on any product containing this material.
7 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
8 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
9 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
10 .TH WCSTOD 3C "Mar 31, 2003"
12 wcstod, wcstof, wcstold, wstod, watof \- convert wide character string to
19 \fBdouble\fR \fBwcstod\fR(\fBconst wchar_t *restrict\fR \fInptr\fR,
20 \fBwchar_t **restrict\fR \fIendptr\fR);
25 \fBfloat\fR \fBwcstof\fR(\fBconst wchar_t *restrict\fR \fInptr\fR,
26 \fBwchar_t **restrict\fR \fIendptr\fR);
31 \fBlong double\fR \fBwcstold\fR(\fBconst wchar_t *restrict\fR \fInptr\fR,
32 \fBwchar_t **restrict\fR \fIendptr\fR);
37 \fBdouble\fR \fBwstod\fR(\fBconst wchar_t *\fR\fInptr\fR, \fBwchar_t **\fR\fIendptr\fR);
42 \fBdouble\fR \fBwatof\fR(\fBwchar_t *\fR\fInptr\fR);
48 The \fBwcstod()\fR, \fBwcstof()\fR, and \fBwcstold()\fR functions convert the
49 initial portion of the wide-character string pointed to by \fInptr\fR to
50 \fBdouble\fR, \fBfloat\fR, and \fBlong double\fR representation, respectively.
51 They first decompose the input wide-character string into three parts:
55 An initial, possibly empty, sequence of white-space wide-character codes (as
56 specified by \fBiswspace\fR(3C))
61 A subject sequence interpreted as a floating-point constant or representing
67 A final wide-character string of one or more unrecognized wide-character
68 codes, including the terminating null wide-character code of the input
69 wide-character string.
73 Then they attempt to convert the subject sequence to a floating-point number,
74 and return the result.
77 The expected form of the subject sequence is an optional plus or minus sign,
78 then one of the following:
83 A non-empty sequence of decimal digits optionally containing a radix character,
84 then an optional exponent part
90 A 0x or 0X, then a non-empty sequence of hexadecimal digits optionally
91 containing a radix character, then an optional binary exponent part
97 One of INF or INFINITY, or any other wide string equivalent except for case
103 One of NAN or NAN(\fIn-wchar-sequence\fR(\fIopt\fR)), or any other wide string
104 ignoring case in the NAN part, where:
111 n-wchar-sequence digit
112 n-wchar-sequence nondigit
119 In default mode for \fBwcstod()\fR, only decimal, INF/INFINITY, and
120 NAN/NAN(\fIn-char-sequence\fR) forms are recognized. In C99/SUSv3 mode,
121 hexadecimal strings are also recognized.
124 In default mode for \fBwcstod()\fR, the \fIn-char-sequence\fR in the
125 NAN(\fIn-char-equence\fR) form can contain any character except ')' (right
126 parenthesis) or '\e0' (null). In C99/SUSv3 mode, the \fIn-char-sequence\fR can
127 contain only upper and lower case letters, digits, and '_' (underscore).
130 The \fBwcstof()\fR and \fBwcstold()\fR functions always function in
131 C99/SUSv3-conformant mode.
134 The subject sequence is defined as the longest initial subsequence of the input
135 wide string, starting with the first non-white-space wide character, that is of
136 the expected form. The subject sequence contains no wide characters if the
137 input wide string is not of the expected form.
140 If the subject sequence has the expected form for a floating-point number, the
141 sequence of wide characters starting with the first digit or the radix
142 character (whichever occurs first) is interpreted as a floating constant
143 according to the rules of the C language, except that the radix character is
144 used in place of a period, and that if neither an exponent part nor a radix
145 character appears in a decimal floating-point number, or if a binary exponent
146 part does not appear in a hexadecimal floating-point number, an exponent part
147 of the appropriate type with value zero is assumed to follow the last digit in
148 the string. If the subject sequence begins with a minus sign, the sequence is
149 interpreted as negated. A wide-character sequence INF or INFINITY is
150 interpreted as an infinity. A wide-character sequence NAN or
151 NAN(\fIn-wchar-sequence\fR(\fIopt\fR)) is interpreted as a quiet NaN. A pointer
152 to the final wide string is stored in the object pointed to by \fIendptr\fR,
153 provided that \fIendptr\fR is not a null pointer.
156 If the subject sequence has either the decimal or hexadecimal form, the value
157 resulting from the conversion is rounded correctly according to the prevailing
158 floating point rounding direction mode. The conversion also raises floating
159 point inexact, underflow, or overflow exceptions as appropriate.
162 The radix character is defined in the program's locale (category
163 \fBLC_NUMERIC\fR). In the POSIX locale, or in a locale where the radix
164 character is not defined, the radix character defaults to a period ('.').
167 If the subject sequence is empty or does not have the expected form, no
168 conversion is performed; the value of \fInptr\fR is stored in the object
169 pointed to by \fIendptr\fR, provided that \fIendptr\fR is not a null pointer.
172 The \fBwcstod()\fR function does not change the setting of \fBerrno\fR if
176 The \fBwstod()\fR function is identical to \fBwcstod()\fR.
179 The \fBwatof\fR(\fIstr\fR) function is equivalent to \fBwstod(\fR\fInptr\fR\fB,
180 (wchar_t **)NULL)\fR.
184 Upon successful completion, these functions return the converted value. If no
185 conversion could be performed, \fB0\fR is returned.
188 If the correct value is outside the range of representable values,
189 \fB\(+-HUGE_VAL\fR, \fB\(+-HUGE_VALF\fR, or \fB\(+-HUGE_VALL\fR is returned
190 (according to the sign of the value), a floating point overflow exception is
191 raised, and \fBerrno\fR is set to \fBERANGE\fR.
194 If the correct value would cause an underflow, the correctly rounded result
195 (which may be normal, subnormal, or zero) is returned, a floating point
196 underflow exception is raised, and \fBerrno\fR is set to \fBERANGE\fR.
200 The \fBwcstod()\fR and \fBwstod()\fR functions will fail if:
207 The value to be returned would cause overflow or underflow.
212 The \fBwcstod()\fR and \fBwcstod()\fR functions may fail if:
219 No conversion could be performed.
225 Because 0 is returned on error and is also a valid return on success, an
226 application wishing to check for error situations should set \fBerrno\fR to 0
227 call \fBwcstod()\fR, \fBwcstof()\fR, \fBwcstold()\fR, or \fBwstod()\fR, then
228 check \fBerrno\fR and if it is non-zero, assume an error has occurred.
232 See \fBattributes\fR(5) for descriptions of the following attributes:
240 ATTRIBUTE TYPE ATTRIBUTE VALUE
242 Interface Stability T{
243 \fBwcstod()\fR, \fBwcstof()\fR, and \fBwcstold()\fR are Standard.
252 \fBiswspace\fR(3C), \fBlocaleconv\fR(3C), \fBscanf\fR(3C), \fBsetlocale\fR(3C),
253 \fBwcstol\fR(3C), \fBattributes\fR(5), \fBstandards\fR(5)