| Deutsch English Français Italiano |
|
<b2a9022a472e580c28007d91d7921d5d@www.novabbs.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: news.eternal-september.org!eternal-september.org!feeder3.eternal-september.org!i2pn.org!i2pn2.org!.POSTED!not-for-mail From: melahi_ahmed@yahoo.fr (ahmed) Newsgroups: comp.lang.forth Subject: Re: May the numbers speak - supplement Date: Thu, 12 Jun 2025 14:04:38 +0000 Organization: novaBBS Message-ID: <b2a9022a472e580c28007d91d7921d5d@www.novabbs.com> References: <20129e22c76a2b18b0a745e9499cbd9b@www.novabbs.com> <nnd$673c55b0$2ad8f129@7aad895b352201b7> <cc0a8c7a3216f3ed508bde73fc8bd422@www.novabbs.com> <feed5481a2c6f29340546fbefb23bb31@www.novabbs.com> <37a6f52a3ab1ec533fcf7ef30beb1022@www.novabbs.com> <nnd$673c55b0$2ad8f129@52950e570341256b> <7c15e1538a1604ad3c7a293ae6196da2530cd1a4@i2pn2.org> <87zfed2sbn.fsf@nightsong.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: i2pn2.org; logging-data="201798"; mail-complaints-to="usenet@i2pn2.org"; posting-account="t+/9LUKLIiUqIe6reyFE7me/EcA/Gr17dRXgwnADesE"; User-Agent: Rocksolid Light X-Spam-Checker-Version: SpamAssassin 4.0.0 X-Rslight-Site: $2y$10$XpudxqX1BWB8Nd.BTsftue.5QG7zi7RsVoJFQyWEgSSLOt8RfXANS X-Rslight-Posting-User: 5f6b2e70af503e44dad56966aa15d35bdef29623 On Thu, 12 Jun 2025 9:59:56 +0000, Paul Rubin wrote: > This version with the string in memory, no error checking, and using a > variable, seems simplest to me. > > variable p > : advance ( -- ) 1 p +! ; > : digit ( -- n ) p @ c@ '0' - advance ; > : 2digit ( -- n ) digit 10 * digit + ; > : hms ( a u -- h m s ) drop p ! > 2digit advance 2digit advance 2digit advance ; > : test clearstack s" 12:34:56" hms ; > > test .s Hi, Thanks for all the ideas. What about this? is it clear, readable, ...? I think it is the same as yours but use directly the return stack and advance manually with subtracting 528 whihc is 48*10+48 where 48 is '0'. : hms ( u n -- h m s) drop >r r@ c@ 10 * r@ 1+ c@ + 528 - r@ 3 + c@ 10 * r@ 4 + c@ + 528 - r@ 6 + c@ 10 * r@ 7 + c@ + 528 - rdrop ; s" 12:34:56" hms .s <3> 12 34 56 ok Ahmed --