| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | C64 BASIC - what`s faster INT() or %? Plus benefits of DEF FN A() |
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: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3) SEEN-BY: 57/0 116/102 153/150 250 317/2 3 393/68 633/267 280 640/384 712/620 SEEN-BY: 712/848 770/0 1 3 100 340 772/0 1 210 500 @PATH: 770/3 1 712/848 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.