Re: Random Numbers


[Prev][Next][Index][Thread]

Re: Random Numbers



Actually, I forgot to reply to this the first time.  Use a random number
generator for 0-255, but do this:

and %00111111

You don't need the first 2 bits if you want a number between 0 and 63 (or 1
and 64, just inc it)

It would greatly increase the speed of generating an appropriate value.
Actually, with 0-63, all you'd have to do is that and it's an appropriate
value.

For 128, do the same but and %01111111.

At 12:06 AM 8/23/97 GMT, you wrote:
>Cause that will eliminate certain numbers.
>
>Ie:
>If a rand number generator returns a number between 1 and 10, and I
>multiply the result by 10, I will never get 53. I suppose I could
>multiply several random numbers, but that does not allow the
>elimination of numbers over 93, etc.
>
>On Fri, 22 Aug 1997 11:18:36 -0400, "Dana Levine"
><alevine@umabnet.ab.umd.edu> wrote:
>
>>Why don't you just get a small random number and then multiply it by an
>>appropriate factor to get a number between 1 and 63?
>>Matt Maurano wrote in message <33f79539.4062169@nntp.best.com>...
>>>I need a random set of coordinates anywhere on the screen (In
>>>82-assembly). Basically, I need a random number function that will
>>>return a number between 1 and 93. It shouldn't be too hard to modify
>>>the code to get a number between 1 and 63 after we get the x
>>>coordinate. The only random number functions I've seen either don't
>>>work, or only work with small values (<15). Any help?
>>
>
>
---
Evil Jim
Viva La Mexico
<eviljim@writeme.com>
http://members.tripod.com/~eviljim/
I want to die in my sleep like my Grandfather, not screaming in pain like
the passengers in my car...


References: