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,328 of 117,927   
   Anton Ertl to Krishna Myneni   
   Re: D! and D@   
   22 Mar 24 17:08:43   
   
   From: anton@mips.complang.tuwien.ac.at   
      
   Krishna Myneni  writes:   
   >In the Forth 2012 standard, and in prior standards, the representation   
   >of double numbers on the stack seems to be allowed to be implementation   
   >defined.   
      
   No, the standard defines it:   
      
   |3.1.4.1 Double-cell integers   
   |   
   |On the stack, the cell containing the most significant part of a   
   |double-cell integer shall be above the cell containing the least   
   |significant part.   
      
   >Thus, on a 32-bit system, the stack order of a 64 bit double   
   >number, the standard does not specify whether the high 32 bits of the   
   >number are on top of the stack or the low 32 bits.   
      
   But it does.   
      
   >Hence, we have the   
   >rationale (A.8.6.1.1140) for the word D>S to abstract the conversion of   
   >a double to single length number (instead of using DROP).   
      
   Have your read the rationale?  It says:   
      
   |There exist number representations, e.g., the sign-magnitude   
   |representation, where reduction from double- to single-precision   
   |cannot simply be done with DROP. This word, equivalent to DROP on   
   |two's complement systems, desensitizes application code to number   
   |representation and facilitates portability.   
      
   So, the rationale says that, if you use the two's-complement   
   representation of negative numbers (as you do), D>S is equivalent to   
   DROP.   
      
   >More generally, the problem with the double number word set is that it   
   >attempts to use the same word set for two different types:   
   >   
   >1) pairs of cell length numbers   
   >2) double length integers   
      
   Standard Forth has the 2... words that work for any pairs of cells,   
   whether they represent double numbers or something else.  The   
   double-number wordset includes some of these words.  Standard Forth   
   also has D... words for dealing with double-cell numbers.  All these   
   words are in the DOUBLE or DOUBLE EXT wordset.   
      
   >It would be better to separate the words for these two types, the latter   
   >having prefix of "D" and the former having prefix "2".   
      
   So what would you do with the 2... words that are in the DOUBLE or   
   DOUBLE EXT wordset?   
      
   I don't think that moving words between wordsets has benefits that   
   exceed the costs.   
      
   - 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 2023: https://euro.theforth.net/2023   
      
   --- 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