1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
.TH ATOI 10.2
.SH NAME
atoi, atol, charstod, strtod, strtol, strtoul, strtoll \- convert text to numbers
.SH SYNOPSIS
.ta \w'\fLdouble 'u
.B
int atoi(char *nptr)
.PP
.B
long atol(char *nptr)
.PP
.B
double charstod(int (*f)(void *), void *a)
.PP
.B
double strtod(char *nptr, char **rptr)
.PP
.B
long strtol(char *nptr, char **rptr, int base)
.PP
.B
ulong strtoul(char *nptr, char **rptr, int base)
.PP
.B
vlong strtoll(char *nptr, char **rptr, int base)
.SH DESCRIPTION
.IR Atoi
and
.I atol
convert a string pointed to by
.I nptr
to integer, and long integer
representation respectively.
The first unrecognized character ends the string.
Leading C escapes are understood, as in
.I strtol
with
.I base
zero.
.PP
.I Atoi
and
.I atol
recognize an optional string of tabs and spaces,
then an optional sign, then a string of
decimal digits.
.PP
.IR Strtod ,
.IR strtol ,
.IR strtoul ,
and
.I strtoll
behave similarly to
.I atol
and, if
.I rptr
is not zero, set
.I *rptr
to point to the input character
immediately after the string converted.
.PP
.I Strtod
recognizes an optional string of tabs and spaces,
then an optional sign, then
a string of digits optionally containing a decimal
point, then an optional
.L e
or
.L E
followed
by an optionally signed integer.
.PP
.IR Strtol ,
.I strtoul
and
.I strtoll
interpret the digit string in the specified
.IR base ,
from 2 to 36,
each digit being less than the base.
Digits with value over 9 are represented by letters,
a-z or A-Z.
If
.I base
is 0, the input is interpreted as an integral constant in
the style of C (with no suffixed type indicators):
numbers are octal if they begin with
.LR 0 ,
hexadecimal if they begin with
.L 0x
or
.LR 0X ,
otherwise decimal.
.I Strtoul
does not recognize signs.
.PP
.I Charstod
interprets floating point numbers in the same syntax as
.IR strtod ,
but it gets successive characters by calling
.BR (*\fIf\fP)(\f2a\f5) .
The last call to
.I f
terminates the scan, so it must have returned a character that
is not a legal continuation of a number.
Therefore, it may be necessary to back up the input stream one character
after calling
.IR charstod .
.SH SOURCE
.B /libkern/atol.c
.br
.B /libkern/charstod.c
.br
.B /libkern/strtod.c
.br
.B /libkern/strtol.c
.br
.B /libkern/strtoul.c
.br
.B /libkern/utils.c
.SH DIAGNOSTICS
Zero is returned if the beginning of the input string is not
interpretable as a number; even in this case,
.I rptr
will be updated.
|