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,397 of 4,328   
   Shaun Bebbington to All   
   C64 BASIC - what's faster INT() or %? Pl   
   16 Apr 18 09:20:04   
   
   There seems to be two ways to do integers on the C64 (and yes I know floats are   
    fastest), I was wondering about these two methods of generating a random   
   positive number between 1 and 64 inclusive:   
      
   10 X=INT(64*RND(0)+1)   
      
   or   
      
   10 X%=64*RND(0)+1   
      
   The latter saves two whole bytes, but is it faster to convert to integer   
   directly with the INT keyword, or is the implicit declaration below faster?   
      
   Second question, let's say you want to generate a random number in multiple   
   places, you could use the above several times in a listing, but one could also   
   define a function as I understand it, like:   
      
   0 DEF FN A(X)=X*RND(0)   
      
   So each time in your listing, you will have,   
      
   10 X%=FN A(39): Y%=FN A(24)   
   ...   
   100 S%=FN A(10)+1: D%=FN A(10)+1   
      
   etc...   
      
   Other than less typing throughout the program (where you might have lots of   
   repeated random number generation in this example), are there any benefits to   
   using CBM functions? Does it save bytes overall would be perhaps one that I   
   could think of.   
      
   Many thanks,   
      
   Shaun.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: SpaceSST BBS Usenet  Fidonet Gateway (255:255/999)   

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


(c) 1994,  bbs@darkrealms.ca