[vcf-midatlantic] Random numbers
Hagstrom, Paul
hagstrom at bu.edu
Fri Apr 7 23:16:41 EDT 2017
> On Apr 7, 2017, at 11:03 PM, Evan Koblentz via vcf-midatlantic <vcf-midatlantic at lists.vintagecomputerfederation.org> wrote:
>
>> If you just generate a bunch of random numbers without doing anything to
>> the number (like INT() or multiplying it) what do you get?
>
> Applesoft generates a decimal value between 0 and 1 if you don't INT or multiply it. You can't do RND(number bigger than 1); it's a syntax error.
>
> If I remove the INT (which rounds down to .0) but keep the multiplication, then I get evens and odds.
>
> I added the INT back because I need whole numbers. But I left out the +1. Now it works as R=INT(RND(1)*38) .... thinking aloud, I have no idea why the +1 was there! :)
The +1 was there so you don't get 0. You wanted a number in the range 1-38. Without +1 it's in the range 0-37.
There's no earthly reason I can think of that you'd just get even numbers with the +1 and not without -- but if you are getting both even and odd numbers without +1, you can just work around whatever it is by just adding another line right after it to increment it:
90 R=INT(RND(1)*38)
91 R=R+1
92 REM NOW R IS BETWEEN 1 AND 38 INCLUSIVE
More information about the vcf-midatlantic
mailing list