Article View: comp.lang.forth
Article #205Re: FCONSTANT specification
From: Anton Ertl
Date: Sat, 31 Oct 2026 07:30
Date: Sat, 31 Oct 2026 07:30
53 lines
3755 bytes
3755 bytes
dxf <dxforth@gmail.com> writes:
>On 30/10/2026 5:47 pm, Anton Ertl wrote:
>> dxf <dxforth@gmail.com> writes:
>>> It's not clear to me that IEEE even talks in terms of 'representable' numbers
>>> which leads to the junk that GCC et al print out:
>>>
>>> 5.1 Overview
>>>
>>> "Each of the computational operations that return a numeric result specified by
>>> this standard shall be performed as if it first produced an intermediate result
>>> correct to infinite precision and with unbounded range, and then rounded that
>>> intermediate result, if necessary, to fit in the destination’s format"
>>
>> This already says it: "if necessary". When the result is
>> representable in the destination's format, rounding is not necessary.
>> When the destination format is a string buffer with enough digits,
>> rounding is not necessary, and the exact value can be shown.
...
>The example I gave - 2/3 to infinity
>'correctly rounded' - starts failing at the 17th digit when stored in binary64.
The value 2/3 cannot be represented with finitely many decimal digits,
nor with finitely many binary digits, and certainly not in binary64.
So when you do, say
2e 3e f/ e.exact
on Gforth (with, e.g., glibc 2.36), what happens is:
2e is converted to binary64, which can be done exactly, so no
rounding is necessary.
3e likewise.
f/ produces a result that cannot be represented exactly in
binary64, so rounding is necessary, and happens. If you want
to call anything "junk" because of lack of exactness, it should
be the result of F/.
e.exact prints the number it finds on the stack, exactly.
Given that we know how 2/3 should look in decimal, the output of
E.EXACT is useful for seeing how the result of F/ differs from the
exact value. If you have no use for such information, use a different
FP printing word, e.g., E.
- 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:
<2026Oct31.083059@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:
<11aide4$1ibse$1@dont-email.me> <11auu2d$3t6hf$2@dont-email.me> <11b2cv4$142ig$1@dont-email.me> <11b2nct$17v9i$1@dont-email.me> <11bl2ar$3lj23$1@dont-email.me> <11bobpu$trdt$1@dont-email.me> <11bogem$vnlk$1@dont-email.me> <6ae16eae$1@news.ausics.net> <11bsn80$2cg90$1@dont-email.me> <6ae2b06f$1@news.ausics.net> <6ae30b4f$1@news.ausics.net> <2026Oct29.101853@mips.complang.tuwien.ac.at> <6ae3e0af$1@news.ausics.net> <2026Oct30.074708@mips.complang.tuwien.ac.at> <6ae56c9a$1@news.ausics.net>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: FCONSTANT specification Date: Sat, 31 Oct 2026 07:30:59 GMT Organization: Institut fuer Computersprachen, Technische Universitaet Wien Lines: 53 Message-ID: <2026Oct31.083059@mips.complang.tuwien.ac.at> References: <11aide4$1ibse$1@dont-email.me> <11auu2d$3t6hf$2@dont-email.me> <11b2cv4$142ig$1@dont-email.me> <11b2nct$17v9i$1@dont-email.me> <11bl2ar$3lj23$1@dont-email.me> <11bobpu$trdt$1@dont-email.me> <11bogem$vnlk$1@dont-email.me> <6ae16eae$1@news.ausics.net> <11bsn80$2cg90$1@dont-email.me> <6ae2b06f$1@news.ausics.net> <6ae30b4f$1@news.ausics.net> <2026Oct29.101853@mips.complang.tuwien.ac.at> <6ae3e0af$1@news.ausics.net> <2026Oct30.074708@mips.complang.tuwien.ac.at> <6ae56c9a$1@news.ausics.net> Injection-Date: Sat, 31 Oct 2026 07:55:37 +0000 (UTC) Injection-Info: dont-email.me; logging-data="973452"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+o9o04xqYJRyQGljCzX+Od"; posting-host="3ac4bdbf86557ee00395b878a304d3f2" Cancel-Lock: sha1:avr79E5Bcx6bcaD5M3uDhg8hxk4= sha256:SYej6/28hIlqQmNx7NOZu72/h64Lbt81b/kRw72wK5s= sha1:5V9H/XXvB7fKKhec7N4erkfSIuY= sha256:/7LFekunLMCxO+BTwextPqTYy09Uk+OTRWD3riIq9GE= X-newsreader: xrn 10.11