diff options
Diffstat (limited to 'src/lib/libc/stdlib/strtod.3')
| -rw-r--r-- | src/lib/libc/stdlib/strtod.3 | 67 |
1 files changed, 41 insertions, 26 deletions
diff --git a/src/lib/libc/stdlib/strtod.3 b/src/lib/libc/stdlib/strtod.3 index 0b7f973857..979334203e 100644 --- a/src/lib/libc/stdlib/strtod.3 +++ b/src/lib/libc/stdlib/strtod.3 | |||
| @@ -13,11 +13,7 @@ | |||
| 13 | .\" 2. Redistributions in binary form must reproduce the above copyright | 13 | .\" 2. Redistributions in binary form must reproduce the above copyright |
| 14 | .\" notice, this list of conditions and the following disclaimer in the | 14 | .\" notice, this list of conditions and the following disclaimer in the |
| 15 | .\" documentation and/or other materials provided with the distribution. | 15 | .\" documentation and/or other materials provided with the distribution. |
| 16 | .\" 3. All advertising materials mentioning features or use of this software | 16 | .\" 3. Neither the name of the University nor the names of its contributors |
| 17 | .\" must display the following acknowledgement: | ||
| 18 | .\" This product includes software developed by the University of | ||
| 19 | .\" California, Berkeley and its contributors. | ||
| 20 | .\" 4. Neither the name of the University nor the names of its contributors | ||
| 21 | .\" may be used to endorse or promote products derived from this software | 17 | .\" may be used to endorse or promote products derived from this software |
| 22 | .\" without specific prior written permission. | 18 | .\" without specific prior written permission. |
| 23 | .\" | 19 | .\" |
| @@ -33,44 +29,62 @@ | |||
| 33 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 34 | .\" SUCH DAMAGE. | 30 | .\" SUCH DAMAGE. |
| 35 | .\" | 31 | .\" |
| 36 | .\" from: @(#)strtod.3 5.3 (Berkeley) 6/29/91 | 32 | .\" $OpenBSD: strtod.3,v 1.12 2008/06/13 23:50:49 jmc Exp $ |
| 37 | .\" $Id: strtod.3,v 1.1.1.1 1995/10/18 08:42:19 deraadt Exp $ | ||
| 38 | .\" | 33 | .\" |
| 39 | .Dd June 29, 1991 | 34 | .Dd $Mdocdate: June 13 2008 $ |
| 40 | .Dt STRTOD 3 | 35 | .Dt STRTOD 3 |
| 41 | .Os | 36 | .Os |
| 42 | .Sh NAME | 37 | .Sh NAME |
| 43 | .Nm strtod | 38 | .Nm strtod , |
| 39 | .Nm strtof | ||
| 44 | .Nd convert | 40 | .Nd convert |
| 45 | .Tn ASCII | 41 | .Tn ASCII |
| 46 | string to double | 42 | string to double or float |
| 47 | .Sh SYNOPSIS | 43 | .Sh SYNOPSIS |
| 44 | .Fd #include <math.h> | ||
| 48 | .Fd #include <stdlib.h> | 45 | .Fd #include <stdlib.h> |
| 49 | .Ft double | 46 | .Ft double |
| 50 | .Fn strtod "const char *nptr" "char **endptr" | 47 | .Fn strtod "const char *nptr" "char **endptr" |
| 48 | .Pp | ||
| 49 | .Ft float | ||
| 50 | .Fn strtof "const char *nptr" "char **endptr" | ||
| 51 | .Sh DESCRIPTION | 51 | .Sh DESCRIPTION |
| 52 | The | 52 | The |
| 53 | .Fn strtod | 53 | .Fn strtod |
| 54 | function converts the initial portion of the string | 54 | function converts the initial portion of the string pointed to by |
| 55 | pointed to by | 55 | .Fa nptr |
| 56 | to | ||
| 57 | .Li double | ||
| 58 | representation. | ||
| 59 | The | ||
| 60 | .Fn strtof | ||
| 61 | function converts the initial portion of the string pointed to by | ||
| 56 | .Fa nptr | 62 | .Fa nptr |
| 57 | to | 63 | to |
| 58 | .Em double | 64 | .Li float |
| 59 | representation. | 65 | representation. |
| 60 | .Pp | 66 | .Pp |
| 61 | The expected form of the string is an optional plus (``+'') or minus | 67 | The expected form of the string is an optional plus |
| 62 | sign (``-'') followed by a sequence of digits optionally containing | 68 | .Pq Ql + |
| 69 | or minus sign | ||
| 70 | .Pq Ql - | ||
| 71 | followed by a sequence of digits optionally containing | ||
| 63 | a decimal-point character, optionally followed by an exponent. | 72 | a decimal-point character, optionally followed by an exponent. |
| 64 | An exponent consists of an ``E'' or ``e'', followed by an optional plus | 73 | An exponent consists of an |
| 65 | or minus sign, followed by a sequence of digits. | 74 | .Sq E |
| 75 | or | ||
| 76 | .Sq e , | ||
| 77 | followed by an optional plus or minus sign, followed by a sequence of digits. | ||
| 66 | .Pp | 78 | .Pp |
| 67 | Leading white-space characters in the string (as defined by the | 79 | Leading whitespace characters in the string (as defined by the |
| 68 | .Xr isspace 3 | 80 | .Xr isspace 3 |
| 69 | function) are skipped. | 81 | function) are skipped. |
| 70 | .Sh RETURN VALUES | 82 | .Sh RETURN VALUES |
| 71 | The | 83 | The |
| 72 | .Fn strtod | 84 | .Fn strtod |
| 73 | function returns the converted value, if any. | 85 | and |
| 86 | .Fn strtof | ||
| 87 | functions return the converted value, if any. | ||
| 74 | .Pp | 88 | .Pp |
| 75 | If | 89 | If |
| 76 | .Fa endptr | 90 | .Fa endptr |
| @@ -88,18 +102,18 @@ is stored in the location referenced by | |||
| 88 | If the correct value would cause overflow, plus or minus | 102 | If the correct value would cause overflow, plus or minus |
| 89 | .Dv HUGE_VAL | 103 | .Dv HUGE_VAL |
| 90 | is returned (according to the sign of the value), and | 104 | is returned (according to the sign of the value), and |
| 91 | .Dv ERANGE | 105 | .Er ERANGE |
| 92 | is stored in | 106 | is stored in |
| 93 | .Va errno . | 107 | .Va errno . |
| 94 | If the correct value would cause underflow, zero is | 108 | If the correct value would cause underflow, zero is returned and |
| 95 | returned and | 109 | .Er ERANGE |
| 96 | .Dv ERANGE | 110 | is stored in |
| 97 | is stored in | ||
| 98 | .Va errno . | 111 | .Va errno . |
| 99 | .Sh ERRORS | 112 | .Sh ERRORS |
| 100 | .Bl -tag -width Er | 113 | .Bl -tag -width Er |
| 101 | .It Bq Er ERANGE | 114 | .It Bq Er ERANGE |
| 102 | Overflow or underflow occurred. | 115 | Overflow or underflow occurred. |
| 116 | .El | ||
| 103 | .Sh SEE ALSO | 117 | .Sh SEE ALSO |
| 104 | .Xr atof 3 , | 118 | .Xr atof 3 , |
| 105 | .Xr atoi 3 , | 119 | .Xr atoi 3 , |
| @@ -109,6 +123,7 @@ Overflow or underflow occurred. | |||
| 109 | .Sh STANDARDS | 123 | .Sh STANDARDS |
| 110 | The | 124 | The |
| 111 | .Fn strtod | 125 | .Fn strtod |
| 112 | function | 126 | and |
| 113 | conforms to | 127 | .Fn strtof |
| 128 | functions conform to | ||
| 114 | .St -ansiC . | 129 | .St -ansiC . |
