mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-05 21:50:55 +11:00
16 lines
362 B
Plaintext
16 lines
362 B
Plaintext
|
( returns negative value on error )
|
||
|
: _ ( c -- n )
|
||
|
( '0' is ASCII 48 )
|
||
|
48 -
|
||
|
DUP 0< IF EXIT THEN ( bad )
|
||
|
DUP 10 < IF EXIT THEN ( good )
|
||
|
( 'a' is ASCII 97. 59 = 97 - 48 )
|
||
|
49 -
|
||
|
DUP 0< IF EXIT THEN ( bad )
|
||
|
DUP 6 < IF 10 + EXIT THEN ( good )
|
||
|
( bad )
|
||
|
255 -
|
||
|
;
|
||
|
|
||
|
|