Handbook
Glossary
digit> ( ch -- n )
Vocabulary
math
.
parser
Inputs
ch
a character
Outputs
n
an
integer
Word description
Converts a character representation of a digit to an integer.
Notes
This is one of the factors of
string>number
.
Definition
USING:
combinators
kernel
math
;
IN:
math.parser
:
digit>
( ch -- n )
{
{
[
dup
57
<=
]
[
48
-
dup
0
<
[
drop
255
]
when
]
}
{
[
dup
97
<
]
[
65 10
-
-
dup
10
<
[
drop
255
]
when
]
}
[
97 10
-
-
dup
10
<
[
drop
255
]
when
]
}
cond
;
inline