🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.forth
Article #65

Re: FCONSTANT specification

#65
From: Krishna Myneni
Date: Mon, 12 Oct 2026 12:31
41 lines
3354 bytes
On 10/12/26 5:40 AM, marcel hendrix wrote:
> In view of the current thread of floating-point input and output, how 
> should we specify FCONSTANTs ? My concern is when the system potentially 
> uses single, double, or extended-double (or worse).
> Is the algorithm that guarantees that a printed number can be converted 
> 'losslessly' back to its internal presentation able to do that 
> regardless of the number of bits in the internal representation?
> 
> We probably don't want that FP library code developed for a double 
> implementation specifies table constants etc. that are depending on the 
> precision of its internal implementation. (I had this problem last week 
> when porting a ddfloat library to xdfloats, although there it was 
> especially tricky.)
> 

There is, of course, no lossless translation of decimal input strings 
into a finite internal binary representation, whether it is single 
precision, double precision, extended precision, or higher. IEEE 754 
does guarantee that a lower precision binary representation is always 
lossless when going to a supported higher precision representation e.g. 
binary32 to binary64.

The implementation of REPRESENT which I've discussed using dtoa() is 
specific to converting decimal strings to internal double precision 
binary format. There are versions of this code for IEEE extended 
precision format, and maybe also for higher precision IEEE formats. 
Please check the netlib page for dtoa.

Your question applies not just to FCONSTANTs but also to FLITERALs. One 
problem with addressing your question is that it depends on a specific 
format, and the Forth standard does not require any particular format. 
If we are talking about internal decimal format only, which no one seems 
to use, then it seems like it would be easy to specify how a decimal 
string should convert to internal representation. For all IEEE binary 
formats, the number of decimal digits which must be specified for 
roundtrip binary -> decimal -> binary are given in the IEEE 754 
standard. For double precision, it is 17.

--
KM
Technical Details
Message-ID: <11aijvt$3iobp$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: <11aide4$1ibse$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: Krishna Myneni <krishna.myneni@ccreweb.org>
Newsgroups: comp.lang.forth
Subject: Re: FCONSTANT specification
Date: Mon, 12 Oct 2026 07:31:57 -0500
Organization: A noiseless patient Spider
Lines: 41
Message-ID: <11aijvt$3iobp$1@dont-email.me>
References: <11aide4$1ibse$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 12 Oct 2026 12:31:59 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="3760505"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+qXfPQg9lJfiXfnyvItmde"; posting-host="0049bcdfbab9457ae4461d9eec926e65"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:Ea1DSeCeGd2ZRdttNPK+Uu1CDD0= sha256:wJF/MjVA1i4UJA0rwRE+g+7XB85bU6LVHruL2ljVzNQ=
	sha1:+SedvY2MAns0oe4uMK6hRpaNLCw= sha256:nU0VTW2hsEueGmGJW7NFPghse6MDuOhhkcbTnH8htvc=
Content-Language: en-US
In-Reply-To: <11aide4$1ibse$1@dont-email.me>