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,237 of 53,866    |
|    Holger to All    |
|    Re: C64 BASIC - what's faster INT() or %    |
|    19 Apr 18 13:21:31    |
      From: hl351ge@gmx.net              Am 17.04.2018 um 04:46 schrieb John H. Guillory:       > SB> For clarification, which is faster?       > SB> 10 X=INT(64*RND(0)+1)       > SB> or       > SB> 10 X%=64*RND(0)+1       >       > Just guessing, I'd say the second one, or 10 X%=64*RND(0)+1       > because in the first, your converting 64*RNND(0)+1 to an integer, then       > converting back to a single precision decimal point value.       >       Effectively, calculations always happen in floating point, and INT()       returns a FP value in the floating point accu. Conversion will take       place on assignment to the destination variable. The INT() operation is       similar to the truncation operation to fit the FP accu value into X%.       In fact, the major difference is that the first line has to copy 5 bytes       into a variable space and the second will copy 2 bytes.              There isn't even an advantage in space requirement for the variable;       both need 7 bytes, i.e. 2 bytes for the name (like A1 or B2% or C3$) and       5 for the value; an integer variable just wastes 3 bytes for the value.       It is different for integer vs. float arrays; in this case a % value is       indeed packed into 2 bytes.              -hl              --- 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