home bbs files messages ]

Just a sample of the Echomail archive

Cooperative anarchy at its finest, still active today. Darkrealms is the Zone 1 Hub.

   CBM      Commodore Computer Conference      4,328 messages   

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

   Message 2,407 of 4,328   
   Shaun Bebbington to All   
   Re: C64 BASIC - what's faster INT() or %   
   18 Apr 18 23:34:56   
   
   After some experimenting it seems that I've been doing random numbers in CBM   
   BASIC completely wrong all of these years. Worse still, all of the examples in   
   the printed literature at the time had the wrong example as well. I assume this   
    is because firstly    
   the least efficient way is more human readable, and secondly it would allow the   
    range of numbers to exceed a 16-bit signed integer range.   
      
   Here is the fastest way to make peusdo-random numbers happen inside the CBM   
   BASIC interpreter, assuming you want a positive integer of between zero and R:   
      
   X%=RND(.)*R   
      
   So, if you require a number higher than +32767, this is the fastest way:   
      
   X=INT(RND(.)*R)   
      
   The ordering seems to be important for optimisation as well, as R*RND(.) is   
   slower because the interpreter re-orders the calculation on the fly according   
   to its precedence.   
      
   I was never made aware of any of these facts as a child BASIC programmer.   
      
   Regards,   
      
   Shaun.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: SpaceSST BBS Usenet  Fidonet Gateway (255:255/999)   

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


(c) 1994,  bbs@darkrealms.ca