Hi i have a few questions which are:
1)Is there anyway of limiting the numbers that varibles can get (no?)
2)What does RANDOMIZE do, that effects RND
3)In the Subs/Functions menu there are numbers after the name, what do they mean?
Thanks
A few questions...
1. No. You have to do this manually.
2. The random number generator applies an algorithm to a sequence of numbers. If it starts with the same "seed" you get the same series of numbers from the rnd function. RANDOMIZE sets the seed.
3. I think those numbers indicate the amount of memory in kilobytes that the procedure occupies after it has been translated to pcode by the interpretor.
2. The random number generator applies an algorithm to a sequence of numbers. If it starts with the same "seed" you get the same series of numbers from the rnd function. RANDOMIZE sets the seed.
3. I think those numbers indicate the amount of memory in kilobytes that the procedure occupies after it has been translated to pcode by the interpretor.
randomize
Randomize re-seeds the random number generator (RNG) but it doesn't "set" the seed. For example:
would be expected to return the same number, but it doesn't. Here's the output from QB 3
(Note: if you restart the program, you'll get the same two numbers.)
if you want to actually SET the seed to, say "555" you have to do this:
From this point on the sequence you get will be the one starting with "555" as a seed.
Code: Select all
randomize 555
print rnd
randomize 555
print rnd
- .9563706
.1887001
(Note: if you restart the program, you'll get the same two numbers.)
if you want to actually SET the seed to, say "555" you have to do this:
Code: Select all
dummy=rnd(-555)
--- Zim ---
--- Time flies like an arrow, but fruit flies like a banana ---
--- Time flies like an arrow, but fruit flies like a banana ---
For the record, Im pretty sure QB running on windows follows this function to generate random numbers:
rand = (seed * 214013 + 2531011) MOD 16777216
seed = rand
whereas the last random number generated is the new seed.
But when we would ask QB for an actual random munber... it returns this instead(frand = rand number that RND returns)
rand = (seed * 214013 + 2531011) MOD 16777216
seed = rand
frand = rand / 16777216
So the new seed isnt actually that number between 0 and 1, its a different number but not the one thet gets returned to us.
rand = (seed * 214013 + 2531011) MOD 16777216
seed = rand
whereas the last random number generated is the new seed.
But when we would ask QB for an actual random munber... it returns this instead(frand = rand number that RND returns)
rand = (seed * 214013 + 2531011) MOD 16777216
seed = rand
frand = rand / 16777216
So the new seed isnt actually that number between 0 and 1, its a different number but not the one thet gets returned to us.
C:\DOS
C:\DOS\RUN
RUN\DOS\RUN
C:\DOS\RUN
RUN\DOS\RUN