home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.forth      Forth programmers eat a lot of Bratwurst      117,927 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 117,693 of 117,927   
   dxf to albert@spenarnc.xs4all.nl   
   Re: Division on riscv   
   09 Nov 25 18:17:34   
   
   From: dxforth@gmail.com   
      
   On 9/11/2025 12:47 am, albert@spenarnc.xs4all.nl wrote:   
   > The division in ciforth was default symmetric. The motivation is that   
   > SM/REM is a wrapper for the single instruction IDIV while floored   
   > is more complicated.   
   > Signed division has a speed advantage for modular arithmetic too.   
   > [   
   >     Normalizing a remainder to the range  0 .. _m is easily done by   
   >   
   >     : _norm_-m  DUP 0< _m @ AND + ;   
   >   
   >     (Note that all constituents are assembler primitives, such that   
   >     they can be collated into one assembler word.)   
   > ]   
   >   
   > There are m modulo classes modulo m. Then it embarrasses mathematicians   
   > that `` I1 @ m MOD ''   and `` I2 @ m MOD '' are not equal,   
   > despite i1 and i2 having the same modulo class.   
   > Symmetric division:   
   > 2 3 MOD .   
   > 2 OK   
   > -1 3 MOD .   
   > -1 OK   
   >   
   > So gforth (at least 0.7.3) avoids this   
   > 2 3 MOD . 2  ok   
   > -1 3 MOD . 2  ok   
   > ...   
      
   2 3 MOD . 2 ok   
   -1 3 MOD . 0 ok   
      
   All 'mod' operators in polyForth were unsigned ;-)   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca