diff options
Diffstat (limited to 'src/lib/libc/stdlib/strtod.3')
-rw-r--r-- | src/lib/libc/stdlib/strtod.3 | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/src/lib/libc/stdlib/strtod.3 b/src/lib/libc/stdlib/strtod.3 new file mode 100644 index 0000000000..f1fc781f7d --- /dev/null +++ b/src/lib/libc/stdlib/strtod.3 | |||
@@ -0,0 +1,145 @@ | |||
1 | .\" Copyright (c) 1990, 1991 The Regents of the University of California. | ||
2 | .\" All rights reserved. | ||
3 | .\" | ||
4 | .\" This code is derived from software contributed to Berkeley by | ||
5 | .\" the American National Standards Committee X3, on Information | ||
6 | .\" Processing Systems. | ||
7 | .\" | ||
8 | .\" Redistribution and use in source and binary forms, with or without | ||
9 | .\" modification, are permitted provided that the following conditions | ||
10 | .\" are met: | ||
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. Neither the name of the University nor the names of its contributors | ||
17 | .\" may be used to endorse or promote products derived from this software | ||
18 | .\" without specific prior written permission. | ||
19 | .\" | ||
20 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
21 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
22 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
23 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
24 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
25 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
26 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
27 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
28 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
30 | .\" SUCH DAMAGE. | ||
31 | .\" | ||
32 | .\" $OpenBSD: strtod.3,v 1.14 2008/09/13 22:48:45 martynas Exp $ | ||
33 | .\" | ||
34 | .Dd $Mdocdate: September 13 2008 $ | ||
35 | .Dt STRTOD 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm strtod , | ||
39 | .Nm strtof , | ||
40 | .Nm strtold | ||
41 | .Nd convert | ||
42 | .Tn ASCII | ||
43 | string to double, float or long double | ||
44 | .Sh SYNOPSIS | ||
45 | .Fd #include <math.h> | ||
46 | .Fd #include <stdlib.h> | ||
47 | .Ft double | ||
48 | .Fn strtod "const char *nptr" "char **endptr" | ||
49 | .Pp | ||
50 | .Ft float | ||
51 | .Fn strtof "const char *nptr" "char **endptr" | ||
52 | .Pp | ||
53 | .Ft long double | ||
54 | .Fn strtold "const char *nptr" "char **endptr" | ||
55 | .Sh DESCRIPTION | ||
56 | The | ||
57 | .Fn strtod | ||
58 | function converts the initial portion of the string pointed to by | ||
59 | .Fa nptr | ||
60 | to | ||
61 | .Li double | ||
62 | representation. | ||
63 | The | ||
64 | .Fn strtof | ||
65 | function converts the initial portion of the string pointed to by | ||
66 | .Fa nptr | ||
67 | to | ||
68 | .Li float | ||
69 | representation. | ||
70 | The | ||
71 | .Fn strtold | ||
72 | function converts the initial portion of the string pointed to by | ||
73 | .Fa nptr | ||
74 | to | ||
75 | .Li long double | ||
76 | representation. | ||
77 | .Pp | ||
78 | The expected form of the string is an optional plus | ||
79 | .Pq Ql + | ||
80 | or minus sign | ||
81 | .Pq Ql - | ||
82 | followed by a sequence of digits optionally containing | ||
83 | a decimal-point character, optionally followed by an exponent. | ||
84 | An exponent consists of an | ||
85 | .Sq E | ||
86 | or | ||
87 | .Sq e , | ||
88 | followed by an optional plus or minus sign, followed by a sequence of digits. | ||
89 | .Pp | ||
90 | Leading whitespace characters in the string (as defined by the | ||
91 | .Xr isspace 3 | ||
92 | function) are skipped. | ||
93 | .Sh RETURN VALUES | ||
94 | The | ||
95 | .Fn strtod , | ||
96 | .Fn strtof | ||
97 | and | ||
98 | .Fn strtold | ||
99 | functions return the converted value, if any. | ||
100 | .Pp | ||
101 | If | ||
102 | .Fa endptr | ||
103 | is not | ||
104 | .Dv NULL , | ||
105 | a pointer to the character after the last character used | ||
106 | in the conversion is stored in the location referenced by | ||
107 | .Fa endptr . | ||
108 | .Pp | ||
109 | If no conversion is performed, zero is returned and the value of | ||
110 | .Fa nptr | ||
111 | is stored in the location referenced by | ||
112 | .Fa endptr . | ||
113 | .Pp | ||
114 | If the correct value would cause overflow, plus or minus | ||
115 | .Dv HUGE_VAL | ||
116 | is returned (according to the sign of the value), and | ||
117 | .Er ERANGE | ||
118 | is stored in | ||
119 | .Va errno . | ||
120 | If the correct value would cause underflow, zero is returned and | ||
121 | .Er ERANGE | ||
122 | is stored in | ||
123 | .Va errno . | ||
124 | .Sh ERRORS | ||
125 | .Bl -tag -width Er | ||
126 | .It Bq Er ERANGE | ||
127 | Overflow or underflow occurred. | ||
128 | .El | ||
129 | .Sh SEE ALSO | ||
130 | .Xr atof 3 , | ||
131 | .Xr atoi 3 , | ||
132 | .Xr atol 3 , | ||
133 | .Xr strtol 3 , | ||
134 | .Xr strtoul 3 | ||
135 | .Sh STANDARDS | ||
136 | The | ||
137 | .Fn strtod | ||
138 | function conforms to | ||
139 | .St -ansiC-89 . | ||
140 | The | ||
141 | .Fn strtof | ||
142 | and | ||
143 | .Fn strtold | ||
144 | functions conform to | ||
145 | .St -ansiC-99 . | ||