Article View: comp.lang.forth
Article #103Re: F.N floating point format word
From: Anton Ertl
Date: Sat, 17 Oct 2026 05:27
Date: Sat, 17 Oct 2026 05:27
67 lines
3131 bytes
3131 bytes
Krishna Myneni <krishna.myneni@ccreweb.org> writes:
>IF ... IF ... ELSE ... ELSE ... THEN THEN
>
>Is this consistent with the standard?
Yes, but
if A if B else C else D THEN THEN
is equivalent to
if A if B D else C then then
and in particular
if A if B swap else C else swap D then then
is also equivalent to
if A if B D else C then then
So one normally would not write code like this. It may be that this
is not the intended code.
OTOH, I have seen code like
swap +
or
does> ;
in production code, so sometimes programmers miss obvious
simplifications; the formatting of the original code may have
contributed to that.
For the code you posted, the simplification would be
over 0< if
dup 0 <= if
nip 0 over 1024 swap - min swap
else \ negative e and n
swap over 1- negate max swap \ limit negative n
then
then \ limit positive n
which can be further simplified (first branch) and unified (second
branch):
over 0< if
dup 0 <= if ( a b
nip 1024 over - 0 min
else \ negative e and n
swap 1 over - max \ limit negative n
then
swap
then \ limit positive n
The similarities between the branches make it plausible that this code
does what is intended.
- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: https://forth-standard.org/
EuroForth 2026 CFP: http://www.euroforth.org/ef26/cfp.html
Technical Details
Message-ID:
<2026Oct17.072757@mips.complang.tuwien.ac.at>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-mailReferences:
<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: anton@mips.complang.tuwien.ac.at (Anton Ertl) Newsgroups: comp.lang.forth Subject: Re: F.N floating point format word Date: Sat, 17 Oct 2026 05:27:57 GMT Organization: Institut fuer Computersprachen, Technische Universitaet Wien Lines: 67 Message-ID: <2026Oct17.072757@mips.complang.tuwien.ac.at> 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> Injection-Date: Sat, 17 Oct 2026 05:47:24 +0000 (UTC) Injection-Info: dont-email.me; logging-data="4129081"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+/dArdvhENSDPEXzjHuIdz"; posting-host="16c33216d85d56b66611c21098e8c6f9" Cancel-Lock: sha1:oylCyDxKTRpTS3EWIjfUuiuIK9s= sha256:MjXpgNDZAofmsbavjZyFd83s/IZ9nGndeYWuIwYRL2A= sha1:zeYfxoctJomIBKF/zH2Roc1bhfM= sha256:AfPLWSYWV3CmmJNAxWx/yDZKUiYK4Osj6lgfXSDN4Ks= X-newsreader: xrn 10.11