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,615 of 117,927   
   Buzz McCool to dxf   
   Re: Average of a [stack]   
   12 Jul 24 10:25:47   
   
   From: buzz_mccool@yahoo.com   
      
   On 7/11/2024 8:53 PM, dxf wrote:   
   > On 12/07/2024 2:35 am, Buzz McCool wrote:   
   >> On 7/10/2024 8:31 PM, dxf wrote:   
   >>> Simpler to count down.  I find it easier writing for a common-stack model.   
   >>>   
   >>> : FloatStackAvg ( rn ... r -- avg )   
   >>>     fdepth dup >r ( count)   
   >>>     begin  1- dup while ( not done)   
   >>>       >r  f+ ( add two floats)  r>   
   >>>     repeat  drop   
   >>>     r> s>f f/ ( sum/count)   
   >>> ;   
   >>>   
   >>   
   >> Thanks for sharing.   
   >>   
   >> What is the purpose of putting something on and then off the return stack   
   on this line?   
   >>>        >r  f+ ( add two floats)  r>   
   >>   
   >> Your example word seemed to work fine without it.   
   >   
   > Traditionally floats existed on the data stack along with integers, doubles   
   etc.   
   > This required being sensitive to what was on top of the stack.  As time   
   passed some   
   > argued floats should have their own stack.  That's now progressed to   
   Forth-200x   
   > outlawing floats on the data stack.  Implementing a separate float stack is   
   usually   
   > no issue for 16-bit processors and above but for 8-bit cpu's it's   
   prohibitive.   
   > My observation is the same people that push for locals also push for floats   
   on a   
   > separate stack using essentially the same argument.   
      
   Thus your earlier comment "I find it easier writing for a common-stack   
   model." which went over my head. Thanks for the explanation.   
      
   --- 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