logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

wcstod.3p (8880B)


  1. '\" et
  2. .TH WCSTOD "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. wcstod,
  12. wcstof,
  13. wcstold
  14. \(em convert a wide-character string to a double-precision number
  15. .SH SYNOPSIS
  16. .LP
  17. .nf
  18. #include <wchar.h>
  19. .P
  20. double wcstod(const wchar_t *restrict \fInptr\fP, wchar_t **restrict \fIendptr\fP);
  21. float wcstof(const wchar_t *restrict \fInptr\fP, wchar_t **restrict \fIendptr\fP);
  22. long double wcstold(const wchar_t *restrict \fInptr\fP,
  23. wchar_t **restrict \fIendptr\fP);
  24. .fi
  25. .SH DESCRIPTION
  26. The functionality described on this reference page is aligned with the
  27. ISO\ C standard. Any conflict between the requirements described here and the
  28. ISO\ C standard is unintentional. This volume of POSIX.1\(hy2017 defers to the ISO\ C standard.
  29. .P
  30. These functions shall convert the initial portion of the wide-character
  31. string pointed to by
  32. .IR nptr
  33. to
  34. .BR double ,
  35. .BR float ,
  36. and
  37. .BR "long double"
  38. representation, respectively. First, they shall decompose the input
  39. wide-character string into three parts:
  40. .IP " 1." 4
  41. An initial, possibly empty, sequence of white-space wide-character
  42. codes (as specified by
  43. \fIiswspace\fR())
  44. .IP " 2." 4
  45. A subject sequence interpreted as a floating-point constant or
  46. representing infinity or NaN
  47. .IP " 3." 4
  48. A final wide-character string of one or more unrecognized wide-character
  49. codes, including the terminating null wide-character code of the input
  50. wide-character string
  51. .P
  52. Then they shall attempt to convert the subject sequence to a
  53. floating-point number, and return the result.
  54. .P
  55. The expected form of the subject sequence is an optional
  56. .BR '+'
  57. or
  58. .BR '\-'
  59. sign, then one of the following:
  60. .IP " *" 4
  61. A non-empty sequence of decimal digits optionally containing a radix
  62. character; then an optional exponent part consisting of the wide
  63. character
  64. .BR 'e'
  65. or the wide character
  66. .BR 'E' ,
  67. optionally followed by a
  68. .BR '+'
  69. or
  70. .BR '\-'
  71. wide character, and then followed by one or more decimal digits
  72. .IP " *" 4
  73. A 0x or 0X, then a non-empty sequence of hexadecimal digits optionally
  74. containing a radix character; then an optional binary exponent part
  75. consisting of the wide character
  76. .BR 'p'
  77. or the wide character
  78. .BR 'P' ,
  79. optionally followed by a
  80. .BR '+'
  81. or
  82. .BR '\-'
  83. wide character, and then followed by one or more decimal digits
  84. .IP " *" 4
  85. One of INF or INFINITY, or any other wide string equivalent except for
  86. case
  87. .IP " *" 4
  88. One of NAN or NAN(\fIn-wchar-sequence\s-3\dopt\u\s+3\fR), or any other
  89. wide string ignoring case in the NAN part, where:
  90. .RS 4
  91. .sp
  92. .RS 4
  93. .nf
  94. n-wchar-sequence:
  95. digit
  96. nondigit
  97. n-wchar-sequence digit
  98. n-wchar-sequence nondigit
  99. .fi
  100. .P
  101. .RE
  102. .RE
  103. .P
  104. The subject sequence is defined as the longest initial subsequence of
  105. the input wide string, starting with the first non-white-space wide
  106. character, that is of the expected form. The subject sequence contains
  107. no wide characters if the input wide string is not of the expected
  108. form.
  109. .P
  110. If the subject sequence has the expected form for a floating-point
  111. number, the sequence of wide characters starting with the first digit
  112. or the radix character (whichever occurs first) shall be interpreted as
  113. a floating constant according to the rules of the C language, except
  114. that the radix character shall be used in place of a period, and that
  115. if neither an exponent part nor a radix character appears in a decimal
  116. floating-point number, or if a binary exponent part does not appear in
  117. a hexadecimal floating-point number, an exponent part of the
  118. appropriate type with value zero shall be assumed to follow the last
  119. digit in the string. If the subject sequence begins with a
  120. <hyphen-minus>,
  121. the sequence shall be interpreted as negated. A wide-character sequence
  122. INF or INFINITY shall be interpreted as an infinity, if representable
  123. in the return type, else as if it were a floating constant that is too
  124. large for the range of the return type. A wide-character sequence NAN
  125. or NAN(\fIn-wchar-sequence\s-3\dopt\u\s+3\fR) shall be interpreted as a
  126. quiet NaN, if supported in the return type, else as if it were a
  127. subject sequence part that does not have the expected form; the meaning
  128. of the \fIn\fP-wchar sequences is implementation-defined. A pointer to
  129. the final wide string shall be stored in the object pointed to by
  130. .IR endptr ,
  131. provided that
  132. .IR endptr
  133. is not a null pointer.
  134. .P
  135. If the subject sequence has the hexadecimal form and FLT_RADIX is a
  136. power of 2, the conversion shall be rounded in an
  137. implementation-defined manner.
  138. .P
  139. The radix character shall be as defined in the current locale
  140. (category
  141. .IR LC_NUMERIC ).
  142. In the POSIX locale, or in a locale where the radix character is not
  143. defined, the radix character shall default to a
  144. <period>
  145. (\c
  146. .BR '.' ).
  147. .P
  148. In other than the C
  149. or POSIX
  150. locale, additional locale-specific subject sequence forms may be
  151. accepted.
  152. .P
  153. If the subject sequence is empty or does not have the expected form, no
  154. conversion shall be performed; the value of
  155. .IR nptr
  156. shall be stored in the object pointed to by
  157. .IR endptr ,
  158. provided that
  159. .IR endptr
  160. is not a null pointer.
  161. .P
  162. These functions shall not change the setting of
  163. .IR errno
  164. if successful.
  165. .P
  166. Since 0 is returned on error and is also a valid return on success,
  167. an application wishing to check for error situations should set
  168. .IR errno
  169. to 0, then call
  170. \fIwcstod\fR(),
  171. \fIwcstof\fR(),
  172. or
  173. \fIwcstold\fR(),
  174. then check
  175. .IR errno .
  176. .SH "RETURN VALUE"
  177. Upon successful completion, these functions shall return the converted
  178. value. If no conversion could be performed, 0 shall be returned
  179. and
  180. .IR errno
  181. may be set to
  182. .BR [EINVAL] .
  183. .P
  184. If the correct value is outside the range of representable values,
  185. \(+-HUGE_VAL, \(+-HUGE_VALF, or \(+-HUGE_VALL shall be returned
  186. (according to the sign of the value), and
  187. .IR errno
  188. shall be set to
  189. .BR [ERANGE] .
  190. .P
  191. If the correct value would cause underflow, a value whose magnitude is
  192. no greater than the smallest normalized positive number in the return
  193. type shall be returned and
  194. .IR errno
  195. set to
  196. .BR [ERANGE] .
  197. .SH ERRORS
  198. The
  199. \fIwcstod\fR()
  200. function shall fail if:
  201. .TP
  202. .BR ERANGE
  203. The value to be returned would cause overflow or underflow.
  204. .P
  205. The
  206. \fIwcstod\fR()
  207. function may fail if:
  208. .TP
  209. .BR EINVAL
  210. No conversion could be performed.
  211. .LP
  212. .IR "The following sections are informative."
  213. .SH EXAMPLES
  214. None.
  215. .SH "APPLICATION USAGE"
  216. If the subject sequence has the hexadecimal form and FLT_RADIX is not a
  217. power of 2, and the result is not exactly representable, the result
  218. should be one of the two numbers in the appropriate internal format
  219. that are adjacent to the hexadecimal floating source value, with the
  220. extra stipulation that the error should have a correct sign for the
  221. current rounding direction.
  222. .P
  223. If the subject sequence has the decimal form and at most DECIMAL_DIG
  224. (defined in
  225. .IR <float.h> )
  226. significant digits, the result should be correctly rounded. If the
  227. subject sequence \fID\fP has the decimal form and more than DECIMAL_DIG
  228. significant digits, consider the two bounding, adjacent decimal strings
  229. \fIL\fP and \fIU\fP, both having DECIMAL_DIG significant digits, such
  230. that the values of \fIL\fP, \fID\fP, and \fIU\fP satisfy
  231. .BR \(dqL <= D <= U\(dq .
  232. The result should be one of the (equal or adjacent) values that would
  233. be obtained by correctly rounding \fIL\fP and \fIU\fP according to the
  234. current rounding direction, with the extra stipulation that the error
  235. with respect to \fID\fP should have a correct sign for the current
  236. rounding direction.
  237. .SH RATIONALE
  238. None.
  239. .SH "FUTURE DIRECTIONS"
  240. None.
  241. .SH "SEE ALSO"
  242. .IR "\fIfscanf\fR\^(\|)",
  243. .IR "\fIiswspace\fR\^(\|)",
  244. .IR "\fIlocaleconv\fR\^(\|)",
  245. .IR "\fIsetlocale\fR\^(\|)",
  246. .IR "\fIwcstol\fR\^(\|)"
  247. .P
  248. The Base Definitions volume of POSIX.1\(hy2017,
  249. .IR "Chapter 7" ", " "Locale",
  250. .IR "\fB<float.h>\fP",
  251. .IR "\fB<wchar.h>\fP"
  252. .\"
  253. .SH COPYRIGHT
  254. Portions of this text are reprinted and reproduced in electronic form
  255. from IEEE Std 1003.1-2017, Standard for Information Technology
  256. -- Portable Operating System Interface (POSIX), The Open Group Base
  257. Specifications Issue 7, 2018 Edition,
  258. Copyright (C) 2018 by the Institute of
  259. Electrical and Electronics Engineers, Inc and The Open Group.
  260. In the event of any discrepancy between this version and the original IEEE and
  261. The Open Group Standard, the original IEEE and The Open Group Standard
  262. is the referee document. The original Standard can be obtained online at
  263. http://www.opengroup.org/unix/online.html .
  264. .PP
  265. Any typographical or formatting errors that appear
  266. in this page are most likely
  267. to have been introduced during the conversion of the source files to
  268. man page format. To report such errors, see
  269. https://www.kernel.org/doc/man-pages/reporting_bugs.html .