From 9461a566ee4bd4cf4073c3fa8b5dc1f0cba0667a Mon Sep 17 00:00:00 2001 From: Koichi Nakamura Date: Mon, 11 Jan 2021 12:01:25 +0900 Subject: [PATCH] Fixed bugs of >number --- bootstrap.fs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/bootstrap.fs b/bootstrap.fs index 7159228..86ce921 100644 --- a/bootstrap.fs +++ b/bootstrap.fs @@ -1112,6 +1112,14 @@ decimal \ set default to decimal nip nip true ; +: parse-int ( u c-addr -- n f ) + dup c@ '-' = if + 1+ parse-uint swap negate swap + else + parse-uint + then +; + \ Parse string as number. \ This function interprets prefixes that specifies number base. : >number ( c-addr -- n f ) @@ -1129,9 +1137,10 @@ decimal \ set default to decimal false then endof - '&' of 1+ 10 swap parse-uint endof - '#' of 1+ 10 swap parse-uint endof - '%' of 1+ 2 swap parse-uint endof + '&' of 1+ 10 swap parse-int endof + '#' of 1+ 10 swap parse-int endof + '$' of 1+ 16 swap parse-int endof + '%' of 1+ 2 swap parse-int endof '0' of \ hexadecimal \ ( addr )