🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.forth
Article #137

Re: F.N floating point format word

#137
From: Krishna Myneni
Date: Mon, 19 Oct 2026 14:44
96 lines
5107 bytes
On 10/19/26 8:41 AM, peter wrote:
> On Sun, 18 Oct 2026 17:10:27 -0500
> Krishna Myneni <krishna.myneni@ccreweb.org> wrote:
> 
>> On 10/8/26 3:07 PM, peter wrote:
>>> On Thu, 8 Oct 2026 09:18:57 -0500
>>> Krishna Myneni <krishna.myneni@ccreweb.org> wrote:
>> ...
>>>>> Thanks to dxf's question I continued testing and found an error.
>>>>>
>>>>> 0.999955555e 2 f.n  0.0100
>>>>>
>>>>> What happened was that in this case exp from the first represent is 0
>>>>> in the test to choose action f.n-case-e<=0 get chosen. In this part
>>>>> exp is recalculated and became 1!
>>>>> The correction is to move the second represent earlier before choosing.
>>>>>
>>>
>>>>
>>>> Would you please attach the complete code when you get a chance since
>>>> several revisions have been made?
>>>>
>>>> Also, I found the following issue with n < 0. It's possible I introduced
>>>> a bug in my revisions of your code, or that I missed some change.
>>>>
>>>> 0.1e -1 (f.n) type 0.1 ok  \ should be "0."
>>>> 0.01e -1 (f.n) type 0.01 ok \ should be "0."
>>>> 0.1e -2 (f.n) type 0.1 ok  \ should be "0."
>>>>
>>>> and similar.
>>>>
>> ...
>>> No they were actually designed to behave like that! I made it so that
>>> when an impossible combination of exp and n were found n was set to a
>>> value that showed the number with one significant digit. That is exactly
>>> what happens in the above tests. But I agree with you when both exp and n
>>> are negative n will be set as 0 and the number rounded to 1. or 0.
>>> I have implemented that test now. I also restructured the code better
>>> and combined 2 cases into one case normal.
>>>
>>> Below follows code for both F.N and (F.N) tested on kForth64
>>>
>> ...
>>>        
>>> \ 0 [IF]
>>> \ Test cases
>>> : testing cr begin refill while source 2dup type space evaluate cr repeat ;
>>> testing
>>> 0.9e  0 f.n
>>> 0.3e  0 f.n
>>> -0.9e 0 f.n
>>> -0.3e 0 f.n
>>> ...
>>
>> I have patched the code with all recent fixes for the logic of (F.N) and
>> revised it to work on both separate stack and unified data/fp stack in
>> fdotn.4th. I have also revised the automated tests in fdotn-test.4th to
>> include your tests. The two files,
>>
>> fdotn.4th
>> fdotn-test.4th
>>
>> may be found in the lastest commits for the git repos for
>> kForth-64/32/Win32 on github or in the repos on ccreweb.org.
>>
>> Direct links to the revised files:
>>
>> https://github.com/mynenik/kForth-64/blob/master/forth-src/fdotn.4th
>> https://github.com/mynenik/kForth-64/blob/master/forth-src/fdotn-test.4th
>>
>> An additional change to the definition of (F.N) prevents the sign on
>> conversion failure from being output except for "inf". The last two
>> tests in fdotn-test.4th have been revised accordingly.
>>
>> --
>> KM
>>
> Nice to see that you could integrate it in kForth!
> 
> I have also introduced it in ntf64/lxf64.
> I liked the possibility to directly specify how many digits to print
> instead of setting precision (that I half of the time misspell!)
> 
> I might do a FS.N where n would be significant digits
> 

Do you mean decimal places? The latest strings library in kForth-x has 
(FS.N) where n is decimal places. I think this corresponds to Fortran 
90's ES<w>.<n> format, but haven't verified it yet.

Normal FS. and (FS.) converts to output in significant digits specified 
via PRECISION.

--
KM
Technical Details
Message-ID: <11b5acr$2579h$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> <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> <11b3g4l$1hubr$1@dont-email.me> <20261019154105.0000595f@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: Mon, 19 Oct 2026 09:44:43 -0500
Organization: A noiseless patient Spider
Lines: 96
Message-ID: <11b5acr$2579h$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> <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>
 <11b3g4l$1hubr$1@dont-email.me> <20261019154105.0000595f@tin.it>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 19 Oct 2026 14:44:44 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="2268465"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+nMBf+M33jNRs/MQJSQy+Z"; posting-host="53448866990c10d050150d317b8d863b"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:L5IUCK/wZXybU5p53c6wdsRPXn8= sha256:nKf/LhfaOmx/mcfmmZ4DpVJVXGxbo8kPNf7mKwTNmiM=
	sha1:uS8FoxRluX6lxyVgeaQcsTosup8= sha256:I97Szx+Mk7LURRi7giYOjX+s1ZqZdIzQitb+93K0/ug=
In-Reply-To: <20261019154105.0000595f@tin.it>
Content-Language: en-US