Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #135035

Re: GNU Forth has a floating point floor word, but not floating point ceiling word?

From peter <peter.noreply@tin.it>
Newsgroups comp.lang.forth
Subject Re: GNU Forth has a floating point floor word, but not floating point ceiling word?
Date 2026-05-01 10:18 +0200
Organization A noiseless patient Spider
Message-ID <20260501101815.000004ef@tin.it> (permalink)
References (2 earlier) <10sooig$2o6bk$1@dont-email.me> <10sv81o$ii2l$1@dont-email.me> <10svbcp$ii2l$2@dont-email.me> <20260430155547.000018f1@tin.it> <10t10r1$13p4b$1@dont-email.me>

Show all headers | View raw


On Thu, 30 Apr 2026 20:49:21 -0500
Krishna Myneni <krishna.myneni@ccreweb.org> wrote:

> On 4/30/26 8:55 AM, peter wrote:
> > On Thu, 30 Apr 2026 05:37:13 -0500
> > Krishna Myneni <krishna.myneni@ccreweb.org> wrote:
> > 
> >> On 4/30/26 4:40 AM, Krishna Myneni wrote:
> >>> On 4/27/26 5:39 PM, Krishna Myneni wrote:
> >>> ...
> >>
> >> Just realized that the following tests are doing nothing more than
> >> testing F= rather than testing FLOOR and FCEIL. In order to test that
> >> FLOOR and FCEIL are returning a valid NAN, one should check the bit
> >> pattern against any valid representation of a NAN.
> >>
> >>> t{ -NAN FLOOR -NAN F= -> false }t
> >>> t{ -NAN FLOOR +NAN F= -> false }t
> >>> t{ +NAN FLOOR -NAN F= -> false }t
> >>> t{ +NAN FLOOR +NAN F= -> false }t
> >>>
> >>
> >>> t{ -NAN FCEIL -NAN F= -> false }t
> >>> t{ -NAN FCEIL +NAN F= -> false }t
> >>> t{ +NAN FCEIL -NAN F= -> false }t
> >>> t{ +NAN FCEIL +NAN F= -> false }t
> >>>
> >> Meaningful tests for FLOOR and FCEIL may be done with the word FNAN?
> >> which checks for any valid representation of NAN. Thus the tests above
> >> should be replaced by
> >>
> >> t{ -NAN FLOOR FNAN? -> true }t
> >> t{ +NAN FLOOR FNAN? -> true }t
> >>
> >> t{ -NAN FCEIL FNAN? -> true }t
> >> t{ +NAN FLOOR FNAN? -> true }t
> >>
> >> The word FNAN? is defined below. Your system must provide the following
> >> words:
> >>
> >> L!  ( n addr -- )  \ perform a 32-bit store to addr
> >> UL@ ( addr -- u )  \ perform an unsigned 32-bit fetch from addr
> >>
> >> For 32-bit systems L! and UL@ are simply ! and @ .
> >> 64-bit systems will need to provide these words intrinsically.
> >>
> >> The revised test code is given below.
> > 
> > Now the test cases run without error on both lxf and lxf64
> > 
> > In lxf64 ABORT" is a compile only word so I just commented out that
> > 
> > I have L@ for zero extended fetch and <L@ for sign extended.
> > That works well also for C@ and <C@ ( and W@, <W@)
> > 
> > I had already FNAN? defined as : FNAN? FDUP F<> ;
> > 
> > Thanks for your test program I found that I had misspelled FCEIL
> > It was named FCIEL, probably after the Italian word cielo (sky)
> > ( I live since more that 30 years in Italy)
> > 
> > More importantly I found that f< and friends behaved differently
> > when they were followed by an IF, not always treating nans correctly
> > 
> 
> Great. Needless to say the exercise helped me as well. There is a memory 
> words proposal that deals with words like UL@ etc. but I'm not sure 
> where it is in the pipeline right now. Gforth also uses UL@ for unsigned 
> 32-bit fetch. kForth uses UL@ and SL@ for unsigned and signed, 
> respectively, and we have UW@ and SW@ -- the mnemonic prefix helps me to 
> use the correct version, especially given how different Forth systems 
> treated W@ as unsigned in some systems and signed in others.
> 
> My definition of FNAN? goes by the ieee 754 definition of what 
> constitutes a NAN, but there may be no practical difference in the two 
> definitions.
> 
> I'm guessing you have a flag use conflict if F< behaves differently when 
> it is followed by an IF.

Yes it was kind of that. In the standalone F> the code becomes

seta al
movzx     rax, al
neg       rax

to set the result of the comparison

followed by an IF it became

jnc	0x????

this means that the true part will also include parity, therefore also nans

the solution is to swap the inputs to use jbe instead
In fact the only tests that can be done without getting NaNs as true are

ja, seta   CF and ZF both 0
jae, setae  CF = 0

to get other comparisons the input will have to be swaped

For F= and F<> there will need to be a test also for parity


> I need to review all of the IEEE fp test code written by the late David 
> N Williams -- I would like to fill in any missing pieces.

That would be greate!

BR
Peter

> Cheers,
> Krishna
> 
> 

Back to comp.lang.forth | Previous | NextPrevious in thread | Find similar


Thread

GNU Forth has a floating point floor word, but not floating point ceiling word? Buzz McCool <buzz_mccool@yahoo.com> - 2026-04-23 16:11 -0700
  Re: GNU Forth has a floating point floor word, but not floating point ceiling word? dxf <dxforth@gmail.com> - 2026-04-24 11:14 +1000
    Re: GNU Forth has a floating point floor word, but not floating point ceiling word? Buzz McCool <buzz_mccool@yahoo.com> - 2026-04-24 08:29 -0700
    Re: GNU Forth has a floating point floor word, but not floating point ceiling word? Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-04-27 17:39 -0500
      Re: GNU Forth has a floating point floor word, but not floating point ceiling word? peter <peter.noreply@tin.it> - 2026-04-28 13:40 +0200
        Re: GNU Forth has a floating point floor word, but not floating point ceiling word? minforth <minforth@gmx.net> - 2026-04-28 14:01 +0200
        Re: GNU Forth has a floating point floor word, but not floating point ceiling word? Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-04-28 19:25 -0500
          Re: GNU Forth has a floating point floor word, but not floating point ceiling word? dxf <dxforth@gmail.com> - 2026-04-29 11:20 +1000
            Re: GNU Forth has a floating point floor word, but not floating point ceiling word? Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-04-29 08:30 -0500
              Re: GNU Forth has a floating point floor word, but not floating point ceiling word? Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-04-29 20:15 -0500
                Re: GNU Forth has a floating point floor word, but not floating point ceiling word? Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-05-02 15:56 -0500
          Re: GNU Forth has a floating point floor word, but not floating point ceiling word? dxf <dxforth@gmail.com> - 2026-04-29 11:47 +1000
      Re: GNU Forth has a floating point floor word, but not floating point ceiling word? Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-04-30 04:40 -0500
        Re: GNU Forth has a floating point floor word, but not floating point ceiling word? Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-04-30 05:37 -0500
          Re: GNU Forth has a floating point floor word, but not floating point ceiling word? peter <peter.noreply@tin.it> - 2026-04-30 15:55 +0200
            Re: GNU Forth has a floating point floor word, but not floating point ceiling word? Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-04-30 20:49 -0500
              Special memory access words (was: GNU Forth has a ...) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2026-05-01 06:16 +0000
                Re: Special memory access words (was: GNU Forth has a ...) peter <peter.noreply@tin.it> - 2026-05-01 10:22 +0200
                Re: Special memory access words (was: GNU Forth has a ...) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2026-05-01 08:57 +0000
                Re: Special memory access words Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-05-01 10:19 -0500
                Re: Special memory access words anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2026-05-01 15:35 +0000
                Re: Special memory access words Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-05-01 13:28 -0500
                Re: Special memory access words Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-05-01 13:30 -0500
                Re: Special memory access words anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2026-05-02 05:54 +0000
                Re: Special memory access words Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-05-02 15:49 -0500
                Re: Special memory access words Hans Bezemer <the.beez.speaks@gmail.com> - 2026-05-01 13:28 +0200
              Re: GNU Forth has a floating point floor word, but not floating point ceiling word? peter <peter.noreply@tin.it> - 2026-05-01 10:18 +0200

csiph-web