2020-10-29 09:06:58 +11:00
|
|
|
: _pd ( a -- n f, parse decimal )
|
|
|
|
C@+ OVER C@ 0 ( a len firstchar startat )
|
|
|
|
( if we have '-', we only advance. more processing later. )
|
|
|
|
SWAP '-' = IF 1+ THEN ( a len startat )
|
2020-10-29 11:29:28 +11:00
|
|
|
( if we can do the whole string, success. if _pdacc returns
|
|
|
|
false before, failure. )
|
2020-10-30 03:34:02 +11:00
|
|
|
0 ROT> ( len ) ( startat ) DO ( a r )
|
2020-10-29 09:06:58 +11:00
|
|
|
OVER I + C@ ( a r c ) _pdacc ( a r f )
|
2020-10-29 11:29:28 +11:00
|
|
|
NOT IF DROP 1- 0 UNLOOP EXIT THEN LOOP ( a r )
|
2020-10-29 09:06:58 +11:00
|
|
|
( if we had '-', we need to invert result. )
|
|
|
|
SWAP C@ '-' = IF 0 -^ THEN 1 ( r 1 ) ;
|