Subj : Re: C64 BASIC - what's faster INT() or %? Plus benefits of DEF FN A() To : All From : Shaun Bebbington Date : Wed Apr 18 2018 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: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3) .