🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.forth
Article #105

Re: F.N floating point format word

#105
From: peter
Date: Sat, 17 Oct 2026 09:52
48 lines
3059 bytes
On Fri, 16 Oct 2026 23:31:07 -0500
Krishna Myneni <krishna.myneni@ccreweb.org> wrote:

> On 10/8/26 3:07 PM, peter wrote:
> ...
> > : f.n ( F:fp n -- )
> ...
> >      over 0< if
> >          dup 0 <= if nip 0 swap else  \ negative e and n
> >                  swap over 1- negate max swap          \ limit negative n
> >          else swap over 1024 swap - min swap then then \ limit positive n
> ...
> 
> > Here is the code for (F.N)
> > 
> > \ (F.N) print float with n decimals to string
> 
> > : (f.n) ( F:fp n -- )
> ...
> >      over 0< if
> >          dup 0 <= if nip 0 swap else  \ negative e and n
> >                   swap over 1- negate max swap             \ limit negative n
> >              else swap over 1024 swap - min swap then then \ limit positive n
> ...
> The code snippets above use a control structure of the form
> 
> IF ... IF ... ELSE ... ELSE ... THEN THEN
> 
> Is this consistent with the standard?
> 
> --
> Krishna

Thanks for noticing this! It might be standard but it does not do 
what it should! The limit positive n does not execute when it should.

Here is a version that corrects this.

over 0 >= if 
   swap over 1024 swap - min swap else   \ limit positive n
   dup 0<= if nip 0 swap else            \ limit negative n when e negative
   1 over - rot max swap then then       \ limit negative n

It worked correctly until I added the test for negative n and e!

BR
Peter
Technical Details
Message-ID: <20261017115221.0000440b@tin.it>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <119oin2$26n99$1@dont-email.me> <11a01mr$sqrm$1@dont-email.me> <20261005150222.00006cf5@tin.it> <11a16nc$1camn$1@dont-email.me> <20261006080347.00002cdf@tin.it> <11a4tj5$2ku7v$1@dont-email.me> <20261007223526.000065ab@tin.it> <6ac7013a$1@news.ausics.net> <20261008121302.00007412@tin.it> <20261008152645.00001682@tin.it> <11a88oh$3t0ti$1@dont-email.me> <20261008220746.0000042f@tin.it> <11autmd$3t6hf$1@dont-email.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: peter <peter.noreply@tin.it>
Newsgroups: comp.lang.forth
Subject: Re: F.N floating point format word
Date: Sat, 17 Oct 2026 11:52:21 +0200
Organization: A noiseless patient Spider
Lines: 48
Message-ID: <20261017115221.0000440b@tin.it>
References: <119oin2$26n99$1@dont-email.me>
	<11a01mr$sqrm$1@dont-email.me>
	<20261005150222.00006cf5@tin.it>
	<11a16nc$1camn$1@dont-email.me>
	<20261006080347.00002cdf@tin.it>
	<11a4tj5$2ku7v$1@dont-email.me>
	<20261007223526.000065ab@tin.it>
	<6ac7013a$1@news.ausics.net>
	<20261008121302.00007412@tin.it>
	<20261008152645.00001682@tin.it>
	<11a88oh$3t0ti$1@dont-email.me>
	<20261008220746.0000042f@tin.it>
	<11autmd$3t6hf$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 17 Oct 2026 09:52:23 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="15802"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18kq6hccrCFVakaM5bulIc3cSVoxoYHRFA="; posting-host="507d3bef6a0b8698f82fc557b52a9e01"
Cancel-Lock: sha1:a0u//waFFdBCKNSpbEyae9kpHZc= sha256:bhlx/AMbiDLpIN8V1Ux5n5SoFDK27vdDv/IQZQ7FCRE=
	sha1:4+cFPgZ1EtoTVBuKGdkeDdiFVm4= sha256:m6vOvjynVBsrFsgtOvCAuBQoYiFKKhD7JXhI/fK/Ugc=
X-Newsreader: Claws Mail 4.4.0 (GTK 3.24.51; x86_64-w64-mingw32)