Sujet : Re: FP number syntax
De : anton (at) *nospam* mips.complang.tuwien.ac.at (Anton Ertl)
Groupes : comp.lang.forthDate : 26. Dec 2024, 09:33:49
Autres entêtes
Organisation : Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID : <2024Dec26.093349@mips.complang.tuwien.ac.at>
References : 1 2 3 4 5 6 7 8 9
User-Agent : xrn 10.11
Paul Rubin <
no.email@nospam.invalid> writes:
dxf <dxforth@gmail.com> writes:
there's been little historical demand '1.34' be recognized as a float.
Depends on how far back in history you go. I have seen quite a few
puzzled questions by people new to Forth who were confused why
something like
1.23 4.56 f+ f.
does not work as they expect. This problem is increased by the
requirement in the standard that
123e f.
prints "123." (maybe with trailing zeros) rather than something that,
when copied and pasted as Forth input, reproduces that number.
There is a reason why Gforth produces warnings when you write numbers
in that way (and that includes writing them as "123.").
It's a mistake I make all the time, but I figure it's one of Forth's
frozen oddities.
It's a backwards compatibility problem, yes, but I see a way to melt
it, see below.
In a non-ANS Forth, I'd probably make 1.34 a float and
use some other scheme for literal doubles.
We have discussed this maybe a decade ago in a Forth200x meeting, and
someone pointed out that we already have that other scheme: For
doubles with decimal base, use
#123.
Similarly for hex and binary base. Doubles in other bases are
extremely rare (I don't think I ever encountered one).
With that in place, the next step in the melting process would be to
make the "123." syntax obsolescent. And then, one standard version
later, destandardize this syntax. Then systems would be free to
interpret "123." as FP number, and I expect that many would switch. I
am less optimistic about standardizing the "123." syntax as indicating
FP, because I expect that there will be systems that stick with "123."
being interpreted as double-cell integer for backward-compatibility
reasons, or to honour the prophet.
- anton
-- M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.htmlcomp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html New standard: https://forth-standard.org/ EuroForth 2024: https://euro.theforth.net