digit> ( ch -- n )


Vocabulary
math.parser

Inputs
cha character


Outputs
nan integer


Word description
Converts a character representation of a digit to an integer.

Notes
This is one of the factors of string>number.

Definition


: 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