Date: Tue, 29 Oct 2024 14:45:34 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Parsing timestamps? Newsgroups: comp.lang.forth References: <1f433fabcb4d053d16cbc098dedc6c370608ac01@i2pn2.org> Content-Language: en-US From: Hans Bezemer In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Message-ID: Organization: KPN B.V. Path: ...!weretis.net!feeder9.news.weretis.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feed.abavia.com!abe007.abavia.com!abp004.abavia.com!news.kpn.nl!not-for-mail Lines: 29 Injection-Date: Tue, 29 Oct 2024 14:45:34 +0100 Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com" Bytes: 1935 On 29-10-2024 10:25, dxf wrote: > On 29/10/2024 4:07 am, Hans Bezemer wrote: >> ... >> I have put the complication elsewhere. If we assume we're working in decimal, you don't even need >NUMBER: >> >> char 0 negate +constant 0- >> >> : /int    ( a1 n1 -- a2 n2 n3) >>   0 >r 1 >r 1- chars over + >>   begin >>    over 1- over < >>   while >>     dup c@ is-digit >>   while >>     dup c@ 0- r> tuck * r> + >r 10 * >r 1- >>   repeat over - rdrop r> -rot >> ; >> ... > > So that's how to convert a numeric string from the other end. > Nice! Easier than I imagined it would be. TORS is the multiplier, 2ORS is the accumulator. Normally, the multiplier is multiplied after each run with BASE @ - but that makes little sense when IS-DIGIT isn't properly adjusted. Would be a nice exercise, though. Hans Bezemer