Article View: comp.lang.forth
Article #8Re: You cannot know how many cells a floating-point number takes?
From: Hans Bezemer
Date: Wed, 07 Oct 2026 07:28
Date: Wed, 07 Oct 2026 07:28
76 lines
4435 bytes
4435 bytes
On 06-10-2026 19:06, Anton Ertl wrote: > Hans Bezemer <the.beez.speaks@gmail.com> writes: >> On 06-10-2026 12:32, marcel hendrix wrote: >>> On 10/6/2026 9:36 AM, Hans Bezemer wrote: >>>> >>>> So it told me -- without ANY doubt whatsoever, that the size of a >>>> FLOAT is equal to the size of a CELL. >>>> >>>> Anybody wants to comment on that? >>> It may tell you the width of its *float stack*, but the items there can >>> be a mix of SFLOAT, DFLOAT, and (probably not) extended floats. >>> >>> -marcel >> >> That's not what the standard says: >> >> 12.6.1.1556 FLOATS FLOATING >> ( n1 -- n2 ) >> n2 is the size in *address units* of n1 floating-point numbers. > > Actually FLOATS tells you something about the number of address units > (bytes) that n1 floats take in memory. It tells you nothing about the > number of cells that a float takes on the data stack. > > The matrix multiplication code determines this hackishly with: > > :noname depth >r 0 0 d>f depth r> - >r fdrop r> ; execute > constant FPCELLWIDTH > > Concerning different FP types, in the standard there is only one FP > type on the FP stack (or, for systems with shared stacks, on the data > stack), represented by r in stack diagrams. SF@ SF! DF@ DF! convert > between the single on-stack FP type and the in-memory FP types, if > necessary. > > - anton By that same way of reasoning, it is significant how much space a character takes up on the data stack. Wow, that's a whopping 64-bits on my system! If you **really** want to waste a lot of precision saving an FP to a variable why should that be of a concern to an implementer? Like I said, the most viable way to use a shared stack -- and produce portable code that works on both shared and separate stacks is to temporarily move integers to the return stack. Let's do crazy: create a separate stack for integers and move them there. Let's even go crazier: let conditional compilation figure it out -- and we've eradicated the problem all together, WHILE retaining the optimal speed for each architecture. But let's return to: "As an additional difficulty, you don't know how many cells a floating-point number takes." I think we can agree that we can determine (without a doubt) how much cells an FVARIABLE takes. Now, let's also assume someone still uses the data stack for FLOATS for some reason. You've demonstrated YOURSELF, it's quite trivial to figure that out. Well, fortunately I DO have such an insane version of the FP library that works from the data stack -- AND uses multiple cells per float: include lib/fp1.4th 23 45 \ let's put some garbage on the datastack depth >r 0 s>f depth >r fdrop r> r> - . cr \ show value drop drop \ let's clean it up It returns 2. So, whatever you DO wanna count, I know how many cells there are in a float. I think that debunks "As an additional difficulty, you don't know how many cells a floating-point number takes" in every sense possible. Hans Bezemer
Technical Details
Message-ID:
<11a4sbf$2l4cs$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-mailReferences:
<11a28dj$1nh2c$1@dont-email.me> <11a2ioh$vi58$1@dont-email.me> <11a3873$2444s$1@dont-email.me> <2026Oct6.190644@mips.complang.tuwien.ac.at>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: Hans Bezemer <the.beez.speaks@gmail.com> Newsgroups: comp.lang.forth Subject: Re: You cannot know how many cells a floating-point number takes? Date: Wed, 7 Oct 2026 09:28:46 +0200 Organization: A noiseless patient Spider Lines: 76 Message-ID: <11a4sbf$2l4cs$1@dont-email.me> References: <11a28dj$1nh2c$1@dont-email.me> <11a2ioh$vi58$1@dont-email.me> <11a3873$2444s$1@dont-email.me> <2026Oct6.190644@mips.complang.tuwien.ac.at> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 07 Oct 2026 07:28:48 +0000 (UTC) Injection-Info: dont-email.me; logging-data="2789788"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/NUSaK8c6u4kvs3vP5MnQY"; posting-host="12c5caa003615669d1567fa5f6d9aa79" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:HJcgtEQjBfG4JIrRLT4qHCzND80= sha256:7UEXl/2sNEyU7T0WlpY6ogAaBOAWynnVBhEOAlhEjdc= sha1:rE/zr5zl3qb38DE3wDKcRzsQzDk= sha256:kKljw0+4HqCDX+hk7o66DV68Yau2H3fG/R/bsOogTgA= Content-Language: en-US In-Reply-To: <2026Oct6.190644@mips.complang.tuwien.ac.at>