🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.forth
Article #11

Re: F.N floating point format word

#11
From: Krishna Myneni
Date: Wed, 07 Oct 2026 07:49
49 lines
2882 bytes
On 10/6/26 1:03 AM, peter wrote:
> On Mon, 5 Oct 2026 17:01:14 -0500
...
> If you are working on (f.n) that I posted there are 2 changes I have made
> later.
> 
> f.n-case-e>0 should be
> 
> : f.n-case-e>0 ( F:fp n e -- )
>      over +                          \ n e+n
>      fpad 1024 '0' fill
>      fpad swap represent 2drop       \ n e'
>      dup >r                          \ n e' r: e'
>      fpad swap stype
>      dup 0 >= if 46 semit then       \ n
>      fpad r> +                       \ n fpad+e'
>      swap 0 max stype ;
> 
> This will prevent the dot to be printed at the end when using negative n.
> 
> The other is in a comment
> 
> : .sign ( f -- )
>      13 and 32 + semit ;             \ prints bl for positive
> \    if 45 semit then ;             \ use this to only print -
> 
> The code I posted have 32 in the commented out part!
> It would print a blank instead of a -
> ...

In the definition of (F.N) you use an argument of u = 32 significant 
digits to REPRESENT. I did not understand why you chose this particular 
number to obtain the decimal exponent (exp). I changed this to 17 and 
all of the tests in fdotn-test.4th still pass.

: (f.n) ...
  fdup fabs fswap fpad ( 32) 17 represent  \ find exp and sign

Since binary -> decimal conversion with 17 significant digits is 
guaranteed to cycle in a round trip for binary64, I think 17 will 
suffice here for obtaining the correct decimal exponent.

--
Krishna


--
Krishna
Technical Details
Message-ID: <11a4tj5$2ku7v$1@dont-email.me>
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>

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: Krishna Myneni <krishna.myneni@ccreweb.org>
Newsgroups: comp.lang.forth
Subject: Re: F.N floating point format word
Date: Wed, 7 Oct 2026 02:49:57 -0500
Organization: A noiseless patient Spider
Lines: 49
Message-ID: <11a4tj5$2ku7v$1@dont-email.me>
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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 07 Oct 2026 07:49:59 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="2783487"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+LVrxAEUdMplfzwrOZR+iB"; posting-host="d05ed1c28a75393cf2b11653aaa7e6f7"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:NDMKz/9NmHNNtGP4BNGBIF6ExyI= sha256:Wx4wtqyYvAlzlNvP1gLgEDNnJscDi9gy5t7ff+1qn38=
	sha1:WAVBvgXs8Qe5HrzH4xJT0+Gojjw= sha256:RHFrxCKZaPdYM0zzXUSirqd9BIfJbi+dqrACIQrWyzw=
Content-Language: en-US
In-Reply-To: <20261006080347.00002cdf@tin.it>