Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.sys.cbm    |    Discussion about Commodore micros    |    53,866 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 52,224 of 53,866    |
|    Shaun Bebbington to All    |
|    C64 BASIC - what's faster INT() or %? Pl    |
|    16 Apr 18 09:20:04    |
      From: shaun@square-circle.co.uk              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: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca