'\" te .\" Copyright (c) 1992, X/Open Company Limited All Rights Reserved Portions Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved .\" 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 .\" http://www.opengroup.org/bookstore/. .\" 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. .\" This notice shall appear on any product containing this material. .\" 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. .\" 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. .\" 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] .TH WCSTOD 3C "Mar 31, 2003" .SH NAME wcstod, wcstof, wcstold, wstod, watof \- convert wide character string to floating-point number .SH SYNOPSIS .LP .nf #include \fBdouble\fR \fBwcstod\fR(\fBconst wchar_t *restrict\fR \fInptr\fR, \fBwchar_t **restrict\fR \fIendptr\fR); .fi .LP .nf \fBfloat\fR \fBwcstof\fR(\fBconst wchar_t *restrict\fR \fInptr\fR, \fBwchar_t **restrict\fR \fIendptr\fR); .fi .LP .nf \fBlong double\fR \fBwcstold\fR(\fBconst wchar_t *restrict\fR \fInptr\fR, \fBwchar_t **restrict\fR \fIendptr\fR); .fi .LP .nf \fBdouble\fR \fBwstod\fR(\fBconst wchar_t *\fR\fInptr\fR, \fBwchar_t **\fR\fIendptr\fR); .fi .LP .nf \fBdouble\fR \fBwatof\fR(\fBwchar_t *\fR\fInptr\fR); .fi .SH DESCRIPTION .sp .LP The \fBwcstod()\fR, \fBwcstof()\fR, and \fBwcstold()\fR functions convert the initial portion of the wide-character string pointed to by \fInptr\fR to \fBdouble\fR, \fBfloat\fR, and \fBlong double\fR representation, respectively. They first decompose the input wide-character string into three parts: .RS +4 .TP 1. An initial, possibly empty, sequence of white-space wide-character codes (as specified by \fBiswspace\fR(3C)) .RE .RS +4 .TP 2. A subject sequence interpreted as a floating-point constant or representing infinity or NaN .RE .RS +4 .TP 3. A final wide-character string of one or more unrecognized wide-character codes, including the terminating null wide-character code of the input wide-character string. .RE .sp .LP Then they attempt to convert the subject sequence to a floating-point number, and return the result. .sp .LP The expected form of the subject sequence is an optional plus or minus sign, then one of the following: .RS +4 .TP .ie t \(bu .el o A non-empty sequence of decimal digits optionally containing a radix character, then an optional exponent part .RE .RS +4 .TP .ie t \(bu .el o A 0x or 0X, then a non-empty sequence of hexadecimal digits optionally containing a radix character, then an optional binary exponent part .RE .RS +4 .TP .ie t \(bu .el o One of INF or INFINITY, or any other wide string equivalent except for case .RE .RS +4 .TP .ie t \(bu .el o One of NAN or NAN(\fIn-wchar-sequence\fR(\fIopt\fR)), or any other wide string ignoring case in the NAN part, where: .sp .in +2 .nf n-wchar-sequence: digit nondigit n-wchar-sequence digit n-wchar-sequence nondigit .fi .in -2 .RE .sp .LP In default mode for \fBwcstod()\fR, only decimal, INF/INFINITY, and NAN/NAN(\fIn-char-sequence\fR) forms are recognized. In C99/SUSv3 mode, hexadecimal strings are also recognized. .sp .LP In default mode for \fBwcstod()\fR, the \fIn-char-sequence\fR in the NAN(\fIn-char-equence\fR) form can contain any character except ')' (right parenthesis) or '\e0' (null). In C99/SUSv3 mode, the \fIn-char-sequence\fR can contain only upper and lower case letters, digits, and '_' (underscore). .sp .LP The \fBwcstof()\fR and \fBwcstold()\fR functions always function in C99/SUSv3-conformant mode. .sp .LP The subject sequence is defined as the longest initial subsequence of the input wide string, starting with the first non-white-space wide character, that is of the expected form. The subject sequence contains no wide characters if the input wide string is not of the expected form. .sp .LP If the subject sequence has the expected form for a floating-point number, the sequence of wide characters starting with the first digit or the radix character (whichever occurs first) is interpreted as a floating constant according to the rules of the C language, except that the radix character is used in place of a period, and that if neither an exponent part nor a radix character appears in a decimal floating-point number, or if a binary exponent part does not appear in a hexadecimal floating-point number, an exponent part of the appropriate type with value zero is assumed to follow the last digit in the string. If the subject sequence begins with a minus sign, the sequence is interpreted as negated. A wide-character sequence INF or INFINITY is interpreted as an infinity. A wide-character sequence NAN or NAN(\fIn-wchar-sequence\fR(\fIopt\fR)) is interpreted as a quiet NaN. A pointer to the final wide string is stored in the object pointed to by \fIendptr\fR, provided that \fIendptr\fR is not a null pointer. .sp .LP If the subject sequence has either the decimal or hexadecimal form, the value resulting from the conversion is rounded correctly according to the prevailing floating point rounding direction mode. The conversion also raises floating point inexact, underflow, or overflow exceptions as appropriate. .sp .LP The radix character is defined in the program's locale (category \fBLC_NUMERIC\fR). In the POSIX locale, or in a locale where the radix character is not defined, the radix character defaults to a period ('.'). .sp .LP If the subject sequence is empty or does not have the expected form, no conversion is performed; the value of \fInptr\fR is stored in the object pointed to by \fIendptr\fR, provided that \fIendptr\fR is not a null pointer. .sp .LP The \fBwcstod()\fR function does not change the setting of \fBerrno\fR if successful. .sp .LP The \fBwstod()\fR function is identical to \fBwcstod()\fR. .sp .LP The \fBwatof\fR(\fIstr\fR) function is equivalent to \fBwstod(\fR\fInptr\fR\fB, (wchar_t **)NULL)\fR. .SH RETURN VALUES .sp .LP Upon successful completion, these functions return the converted value. If no conversion could be performed, \fB0\fR is returned. .sp .LP If the correct value is outside the range of representable values, \fB\(+-HUGE_VAL\fR, \fB\(+-HUGE_VALF\fR, or \fB\(+-HUGE_VALL\fR is returned (according to the sign of the value), a floating point overflow exception is raised, and \fBerrno\fR is set to \fBERANGE\fR. .sp .LP If the correct value would cause an underflow, the correctly rounded result (which may be normal, subnormal, or zero) is returned, a floating point underflow exception is raised, and \fBerrno\fR is set to \fBERANGE\fR. .SH ERRORS .sp .LP The \fBwcstod()\fR and \fBwstod()\fR functions will fail if: .sp .ne 2 .na \fB\fBERANGE\fR\fR .ad .RS 10n The value to be returned would cause overflow or underflow. .RE .sp .LP The \fBwcstod()\fR and \fBwcstod()\fR functions may fail if: .sp .ne 2 .na \fB\fBEINVAL\fR\fR .ad .RS 10n No conversion could be performed. .RE .SH USAGE .sp .LP Because 0 is returned on error and is also a valid return on success, an application wishing to check for error situations should set \fBerrno\fR to 0 call \fBwcstod()\fR, \fBwcstof()\fR, \fBwcstold()\fR, or \fBwstod()\fR, then check \fBerrno\fR and if it is non-zero, assume an error has occurred. .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS box; l | l l | l . ATTRIBUTE TYPE ATTRIBUTE VALUE _ Interface Stability T{ \fBwcstod()\fR, \fBwcstof()\fR, and \fBwcstold()\fR are Standard. T} _ MT-Level MT-Safe .TE .SH SEE ALSO .sp .LP \fBiswspace\fR(3C), \fBlocaleconv\fR(3C), \fBscanf\fR(3C), \fBsetlocale\fR(3C), \fBwcstol\fR(3C), \fBattributes\fR(5), \fBstandards\fR(5)