26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
44 .\" Portions Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved
45 .\"
46 .TH WCSTOD 3C "Mar 31, 2003"
47 .SH NAME
48 wcstod, wcstof, wcstold, wstod, watof \- convert wide character string to
49 floating-point number
50 .SH SYNOPSIS
51 .LP
52 .nf
53 #include <wchar.h>
54
55 \fBdouble\fR \fBwcstod\fR(\fBconst wchar_t *restrict\fR \fInptr\fR,
56 \fBwchar_t **restrict\fR \fIendptr\fR);
57 .fi
58
59 .LP
60 .nf
61 \fBfloat\fR \fBwcstof\fR(\fBconst wchar_t *restrict\fR \fInptr\fR,
62 \fBwchar_t **restrict\fR \fIendptr\fR);
63 .fi
64
65 .LP
66 .nf
67 \fBlong double\fR \fBwcstold\fR(\fBconst wchar_t *restrict\fR \fInptr\fR,
68 \fBwchar_t **restrict\fR \fIendptr\fR);
69 .fi
70
71 .LP
72 .nf
73 \fBdouble\fR \fBwstod\fR(\fBconst wchar_t *\fR\fInptr\fR, \fBwchar_t **\fR\fIendptr\fR);
74 .fi
75
76 .LP
77 .nf
78 \fBdouble\fR \fBwatof\fR(\fBwchar_t *\fR\fInptr\fR);
79 .fi
80
81 .SH DESCRIPTION
82 .sp
83 .LP
84 The \fBwcstod()\fR, \fBwcstof()\fR, and \fBwcstold()\fR functions convert the
85 initial portion of the wide-character string pointed to by \fInptr\fR to
86 \fBdouble\fR, \fBfloat\fR, and \fBlong double\fR representation, respectively.
87 They first decompose the input wide-character string into three parts:
88 .RS +4
89 .TP
90 1.
91 An initial, possibly empty, sequence of white-space wide-character codes (as
92 specified by \fBiswspace\fR(3C))
93 .RE
94 .RS +4
95 .TP
96 2.
97 A subject sequence interpreted as a floating-point constant or representing
98 infinity or NaN
99 .RE
100 .RS +4
101 .TP
102 3.
103 A final wide-character string of one or more unrecognized wide-character
136 .TP
137 .ie t \(bu
138 .el o
139 One of NAN or NAN(\fIn-wchar-sequence\fR(\fIopt\fR)), or any other wide string
140 ignoring case in the NAN part, where:
141 .sp
142 .in +2
143 .nf
144 n-wchar-sequence:
145 digit
146 nondigit
147 n-wchar-sequence digit
148 n-wchar-sequence nondigit
149 .fi
150 .in -2
151
152 .RE
153 .sp
154 .LP
155 In default mode for \fBwcstod()\fR, only decimal, INF/INFINITY, and
156 NAN/NAN(\fIn-char-sequence\fR) forms are recognized. In C99/SUSv3 mode,
157 hexadecimal strings are also recognized.
158 .sp
159 .LP
160 In default mode for \fBwcstod()\fR, the \fIn-char-sequence\fR in the
161 NAN(\fIn-char-equence\fR) form can contain any character except ')' (right
162 parenthesis) or '\e0' (null). In C99/SUSv3 mode, the \fIn-char-sequence\fR can
163 contain only upper and lower case letters, digits, and '_' (underscore).
164 .sp
165 .LP
166 The \fBwcstof()\fR and \fBwcstold()\fR functions always function in
167 C99/SUSv3-conformant mode.
168 .sp
169 .LP
170 The subject sequence is defined as the longest initial subsequence of the input
171 wide string, starting with the first non-white-space wide character, that is of
172 the expected form. The subject sequence contains no wide characters if the
173 input wide string is not of the expected form.
174 .sp
175 .LP
176 If the subject sequence has the expected form for a floating-point number, the
177 sequence of wide characters starting with the first digit or the radix
178 character (whichever occurs first) is interpreted as a floating constant
179 according to the rules of the C language, except that the radix character is
180 used in place of a period, and that if neither an exponent part nor a radix
181 character appears in a decimal floating-point number, or if a binary exponent
182 part does not appear in a hexadecimal floating-point number, an exponent part
198 The radix character is defined in the program's locale (category
199 \fBLC_NUMERIC\fR). In the POSIX locale, or in a locale where the radix
200 character is not defined, the radix character defaults to a period ('.').
201 .sp
202 .LP
203 If the subject sequence is empty or does not have the expected form, no
204 conversion is performed; the value of \fInptr\fR is stored in the object
205 pointed to by \fIendptr\fR, provided that \fIendptr\fR is not a null pointer.
206 .sp
207 .LP
208 The \fBwcstod()\fR function does not change the setting of \fBerrno\fR if
209 successful.
210 .sp
211 .LP
212 The \fBwstod()\fR function is identical to \fBwcstod()\fR.
213 .sp
214 .LP
215 The \fBwatof\fR(\fIstr\fR) function is equivalent to \fBwstod(\fR\fInptr\fR\fB,
216 (wchar_t **)NULL)\fR.
217 .SH RETURN VALUES
218 .sp
219 .LP
220 Upon successful completion, these functions return the converted value. If no
221 conversion could be performed, \fB0\fR is returned.
222 .sp
223 .LP
224 If the correct value is outside the range of representable values,
225 \fB\(+-HUGE_VAL\fR, \fB\(+-HUGE_VALF\fR, or \fB\(+-HUGE_VALL\fR is returned
226 (according to the sign of the value), a floating point overflow exception is
227 raised, and \fBerrno\fR is set to \fBERANGE\fR.
228 .sp
229 .LP
230 If the correct value would cause an underflow, the correctly rounded result
231 (which may be normal, subnormal, or zero) is returned, a floating point
232 underflow exception is raised, and \fBerrno\fR is set to \fBERANGE\fR.
233 .SH ERRORS
234 .sp
235 .LP
236 The \fBwcstod()\fR and \fBwstod()\fR functions will fail if:
237 .sp
238 .ne 2
239 .na
240 \fB\fBERANGE\fR\fR
241 .ad
242 .RS 10n
243 The value to be returned would cause overflow or underflow.
244 .RE
245
246 .sp
247 .LP
248 The \fBwcstod()\fR and \fBwcstod()\fR functions may fail if:
249 .sp
250 .ne 2
251 .na
252 \fB\fBEINVAL\fR\fR
253 .ad
254 .RS 10n
255 No conversion could be performed.
256 .RE
257
258 .SH USAGE
259 .sp
260 .LP
261 Because 0 is returned on error and is also a valid return on success, an
262 application wishing to check for error situations should set \fBerrno\fR to 0
263 call \fBwcstod()\fR, \fBwcstof()\fR, \fBwcstold()\fR, or \fBwstod()\fR, then
264 check \fBerrno\fR and if it is non-zero, assume an error has occurred.
265 .SH ATTRIBUTES
266 .sp
267 .LP
268 See \fBattributes\fR(5) for descriptions of the following attributes:
269 .sp
270
271 .sp
272 .TS
273 box;
274 l | l
275 l | l .
276 ATTRIBUTE TYPE ATTRIBUTE VALUE
277 _
278 Interface Stability T{
279 \fBwcstod()\fR, \fBwcstof()\fR, and \fBwcstold()\fR are Standard.
280 T}
281 _
282 MT-Level MT-Safe
283 .TE
284
285 .SH SEE ALSO
286 .sp
287 .LP
288 \fBiswspace\fR(3C), \fBlocaleconv\fR(3C), \fBscanf\fR(3C), \fBsetlocale\fR(3C),
289 \fBwcstol\fR(3C), \fBattributes\fR(5), \fBstandards\fR(5)
|
26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
44 .\" Portions Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved
45 .\"
46 .TH WCSTOD 3C "Aug 25, 2019"
47 .SH NAME
48 wcstod, wcstof, wcstold, wstod, watof \- convert wide character string to
49 floating-point number
50 .SH SYNOPSIS
51 .nf
52 #include <wchar.h>
53
54 \fBdouble\fR \fBwcstod\fR(\fBconst wchar_t *restrict\fR \fInptr\fR,
55 \fBwchar_t **restrict\fR \fIendptr\fR);
56 .fi
57
58 .LP
59 .nf
60 \fBfloat\fR \fBwcstof\fR(\fBconst wchar_t *restrict\fR \fInptr\fR,
61 \fBwchar_t **restrict\fR \fIendptr\fR);
62 .fi
63
64 .LP
65 .nf
66 \fBlong double\fR \fBwcstold\fR(\fBconst wchar_t *restrict\fR \fInptr\fR,
67 \fBwchar_t **restrict\fR \fIendptr\fR);
68 .fi
69
70 .LP
71 .nf
72 \fBdouble\fR \fBwstod\fR(\fBconst wchar_t *\fR\fInptr\fR, \fBwchar_t **\fR\fIendptr\fR);
73 .fi
74
75 .LP
76 .nf
77 \fBdouble\fR \fBwatof\fR(\fBwchar_t *\fR\fInptr\fR);
78 .fi
79
80 .SH DESCRIPTION
81 The \fBwcstod()\fR, \fBwcstof()\fR, and \fBwcstold()\fR functions convert the
82 initial portion of the wide-character string pointed to by \fInptr\fR to
83 \fBdouble\fR, \fBfloat\fR, and \fBlong double\fR representation, respectively.
84 They first decompose the input wide-character string into three parts:
85 .RS +4
86 .TP
87 1.
88 An initial, possibly empty, sequence of white-space wide-character codes (as
89 specified by \fBiswspace\fR(3C))
90 .RE
91 .RS +4
92 .TP
93 2.
94 A subject sequence interpreted as a floating-point constant or representing
95 infinity or NaN
96 .RE
97 .RS +4
98 .TP
99 3.
100 A final wide-character string of one or more unrecognized wide-character
133 .TP
134 .ie t \(bu
135 .el o
136 One of NAN or NAN(\fIn-wchar-sequence\fR(\fIopt\fR)), or any other wide string
137 ignoring case in the NAN part, where:
138 .sp
139 .in +2
140 .nf
141 n-wchar-sequence:
142 digit
143 nondigit
144 n-wchar-sequence digit
145 n-wchar-sequence nondigit
146 .fi
147 .in -2
148
149 .RE
150 .sp
151 .LP
152 In default mode for \fBwcstod()\fR, only decimal, INF/INFINITY, and
153 NAN/NAN(\fIn-wchar-sequence\fR) forms are recognized. In C99/SUSv3 mode,
154 hexadecimal strings are also recognized.
155 .sp
156 .LP
157 In default mode for \fBwcstod()\fR, the \fIn-wchar-sequence\fR in the
158 NAN(\fIn-wchar-sequence\fR) form can contain any character except ')' (right
159 parenthesis) or '\e0' (null). In C99/SUSv3 mode, the \fIn-wchar-sequence\fR can
160 contain only upper and lower case letters, digits, and '_' (underscore).
161 .sp
162 .LP
163 The \fBwcstof()\fR and \fBwcstold()\fR functions always function in
164 C99/SUSv3-conformant mode.
165 .sp
166 .LP
167 The subject sequence is defined as the longest initial subsequence of the input
168 wide string, starting with the first non-white-space wide character, that is of
169 the expected form. The subject sequence contains no wide characters if the
170 input wide string is not of the expected form.
171 .sp
172 .LP
173 If the subject sequence has the expected form for a floating-point number, the
174 sequence of wide characters starting with the first digit or the radix
175 character (whichever occurs first) is interpreted as a floating constant
176 according to the rules of the C language, except that the radix character is
177 used in place of a period, and that if neither an exponent part nor a radix
178 character appears in a decimal floating-point number, or if a binary exponent
179 part does not appear in a hexadecimal floating-point number, an exponent part
195 The radix character is defined in the program's locale (category
196 \fBLC_NUMERIC\fR). In the POSIX locale, or in a locale where the radix
197 character is not defined, the radix character defaults to a period ('.').
198 .sp
199 .LP
200 If the subject sequence is empty or does not have the expected form, no
201 conversion is performed; the value of \fInptr\fR is stored in the object
202 pointed to by \fIendptr\fR, provided that \fIendptr\fR is not a null pointer.
203 .sp
204 .LP
205 The \fBwcstod()\fR function does not change the setting of \fBerrno\fR if
206 successful.
207 .sp
208 .LP
209 The \fBwstod()\fR function is identical to \fBwcstod()\fR.
210 .sp
211 .LP
212 The \fBwatof\fR(\fIstr\fR) function is equivalent to \fBwstod(\fR\fInptr\fR\fB,
213 (wchar_t **)NULL)\fR.
214 .SH RETURN VALUES
215 Upon successful completion, these functions return the converted value. If no
216 conversion could be performed, \fB0\fR is returned.
217 .sp
218 .LP
219 If the correct value is outside the range of representable values,
220 \fB\(+-HUGE_VAL\fR, \fB\(+-HUGE_VALF\fR, or \fB\(+-HUGE_VALL\fR is returned
221 (according to the sign of the value), a floating point overflow exception is
222 raised, and \fBerrno\fR is set to \fBERANGE\fR.
223 .sp
224 .LP
225 If the correct value would cause an underflow, the correctly rounded result
226 (which may be normal, subnormal, or zero) is returned, a floating point
227 underflow exception is raised, and \fBerrno\fR is set to \fBERANGE\fR.
228 .SH ERRORS
229 The \fBwcstod()\fR and \fBwstod()\fR functions will fail if:
230 .sp
231 .ne 2
232 .na
233 \fBERANGE\fR
234 .ad
235 .RS 10n
236 The value to be returned would cause overflow or underflow.
237 .RE
238
239 .sp
240 .LP
241 The \fBwcstod()\fR and \fBwcstod()\fR functions may fail if:
242 .sp
243 .ne 2
244 .na
245 \fBEINVAL\fR
246 .ad
247 .RS 10n
248 No conversion could be performed.
249 .RE
250
251 .SH USAGE
252 Because 0 is returned on error and is also a valid return on success, an
253 application wishing to check for error situations should set \fBerrno\fR to 0
254 call \fBwcstod()\fR, \fBwcstof()\fR, \fBwcstold()\fR, or \fBwstod()\fR, then
255 check \fBerrno\fR and if it is non-zero, assume an error has occurred.
256 .SH ATTRIBUTES
257 See \fBattributes\fR(5) for descriptions of the following attributes:
258 .sp
259
260 .sp
261 .TS
262 box;
263 l | l
264 l | l .
265 ATTRIBUTE TYPE ATTRIBUTE VALUE
266 _
267 Interface Stability T{
268 \fBwcstod()\fR, \fBwcstof()\fR, and \fBwcstold()\fR are Standard.
269 T}
270 _
271 MT-Level MT-Safe
272 .TE
273
274 .SH SEE ALSO
275 \fBiswspace\fR(3C), \fBlocaleconv\fR(3C), \fBscanf\fR(3C), \fBsetlocale\fR(3C),
276 \fBwcstol\fR(3C), \fBattributes\fR(5), \fBstandards\fR(5)
|