Randomize Timer
Author Message Randomize Timer

Does anyone know how to increase the variables of the INT(RND* #) -#
What I mean is I need the randomize timer to produce numbers from 1 to
--
~Lamaal Brown http://www.*-*-*.com/ ~brown5/tlbsite

Fri, 26 May 2000 03:00:00 GMT  Randomize Timer

Deloris,

I'm fairly new with QBasic, but this might help.

CLS
RANDOMIZE TIMER
start TIMER
FOR k% = 1 TO 1000
product = 1.23 * 4.56
next k%
finish=timer
PRINT " Elasped time:"; finish - start
END

hope this helps
SammyD

Quote:
> Does anyone know how to increase the variables of the INT(RND* #) -#
> What I mean is I need the randomize timer to produce numbers from 1 to
> --

Tue, 30 May 2000 03:00:00 GMT  Randomize Timer

+AD4-        I'm fairly new with QBasic, but this might help.
+AD4-PRINT +ACI- Elasped time:+ACIAOw- finish - start
+AD4APg- Does anyone know how to increase the variables of the INT(RND+ACo- +ACM-) -+ACM-
+AD4APg- What I mean is I need the randomize timer to produce numbers from 1 to

Is  Lamaal asking how to generate numbers from 1 to 1000?  If so, you don't
need the TIMER to do that.  To generate a random number from 1 - 1000, use

INT(1000 +ACo- RND) +- 1

Tom Lake

Tue, 30 May 2000 03:00:00 GMT  Randomize Timer

Quote:

> Does anyone know how to increase the variables of the INT(RND* #) -#
> What I mean is I need the randomize timer to produce numbers from 1 to
> --

With UB=<upper boundary> (=1000) and LB=<lower boundary> (=1) the
formula is: RandNoBetweenLBandUB = (UB - LB + 1)*RND + LB
To get integer-numbers use the INT()-function.

ciao
Enno

Tue, 30 May 2000 03:00:00 GMT  Randomize Timer

Quote:

> > Does anyone know how to increase the variables of the INT(RND* #) -#
> > What I mean is I need the randomize timer to produce numbers from 1 to
> > --

> With UB=<upper boundary> (=1000) and LB=<lower boundary> (=1) the
> formula is: RandNoBetweenLBandUB = (UB - LB + 1)*RND + LB
> To get integer-numbers use the INT()-function.

Enno is correct, and gives the general formula.  When generating pseudo
random integers from 1 to N the general formula can be reduced to:

RandomInteger = INT(RND * N) + 1

So the original poster can get random integers from 1 to 1000 by using:

RandomInteger = INT(RND * 1000) + 1
--
Judson McClendon          This is a faithful saying and worthy of all
Sun Valley Systems        acceptance, that Christ Jesus came into the

(please remove zzz from email id to respond)

Tue, 30 May 2000 03:00:00 GMT  Randomize Timer

Quote:
> Does anyone know how to increase the variables of the INT(RND* #) -#
> What I mean is I need the randomize timer to produce numbers from 1 to

I use this little function....

FUNCTION fRND%( Low%, High% )

fRND% = ( RND * (High%-Low%) ) + Low%

END FUNCTION

RANDOMIZE TIMER only sets the 'SEED' number to whatever value the TIMER
function returns and is generally used to ensure different results each time
the program is run.

C'ya,

____    _    ____      ____  _____
|  _ \  / \  / ___) __ | ___)(_   _)
| |_)  / _ \ \____\/  \|  _)   | |
|____//_/ \_\(____/\__/|_|     |_|

www.basicguru.com/schullian

Tue, 30 May 2000 03:00:00 GMT  Randomize Timer

Quote:
> Does anyone know how to increase the variables of the INT(RND* #) -#
> What I mean is I need the randomize timer to produce numbers from 1 to

Random numbers up to 1000 work on my qbasic, using the following code;

RANDOMIZE TIMER 'Put this at the start to choose a start position
based on                 'the motherboard clock

x=INT(RND*1000)+1       'Use this to generate a random number from 1 to 1000
'and store it in varable x. Change the number
1000                         'to whatever you need.

print x                 'Self explanatory, really.

HTH
Simon.

Tue, 30 May 2000 03:00:00 GMT  Randomize Timer

DB>Does anyone know how to increase the variables of the INT(RND* #) -#
DB>What I mean is I need the randomize timer to produce numbers from 1 to

First, remember to use:

RANDOMIZE TIMER

in your program to seed the random number generator before you use the
RND function in your program. One formula for generating random numbers
is:

High% = 1000  ' highest number that can occur
Low% = 1      ' lowest number that can occur
ARndNumber% = INT((High% - Low% + 1) * RND + Low%)

Hope that helps. Good luck!

- Robert

* OLX 2.1 TD * \$1,000,000 reward for finding this man:

Wed, 31 May 2000 03:00:00 GMT

 Page 1 of 1 [ 8 post ]

Relevant Pages