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 116,373 of 117,927   
   Hans Bezemer to Krishna Myneni   
   Re: DLSHIFT and DRSHIFT   
   29 Mar 24 14:03:55   
   
   From: the.beez.speaks@gmail.com   
      
   On 27-03-2024 01:57, Krishna Myneni wrote:   
   > On 3/26/24 17:01, Krishna Myneni wrote:   
   >> Standard source definitions of DLSHIFT and DRSHIFT (double number left   
   >> shift and right shift), over full shift range, per discussion in prior   
   >> thread.   
   >>   
   >> Tests needed.   
   >   
   > Just tested DLSHIFT and found weird things going on. Traced the problem   
   > to LSHIFT.   
      
   Yep. That's why I had to create this horrible code in order to force the   
   compiler to give me the behavior I want:   
      
               CODE (SHIFT)    DSIZE (2); a = DPOP;   
                               b = (sizeof (cell) * CHAR_BIT);   
                               if ((a < b) && (a > -b))   
                                  {         /* within cell size? */   
                                    if (a < 0L)   
                                       {    /* force logical right shift */   
                                         DS (1) = (DS (1) >> 1L) & CELL_MAX;   
                                         a = -1L - a; DS (1) >>= a;   
                                       }    /* shift one bit, clear it */   
                                    else DS (1) <<= a;   
                                  }         /* we're in zero territory now */   
                               else DS (1) = 0L;   
                               NEXT;   
      
   Hans Bezemer   
      
   --- 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