0

I am really confused on this problem someone please assist me I am suppose to create a random number generator that passes in a high and low value and return a random number using a generator that is not biased. It makes use of the idea of cuttoff. I know there are better generators but I have to use this one Here is the code that I have.
long randint(long low, long high)
{
s=MAX/(n+1);
cutoff=s*(n+1);
while((r=rng()) >= cutoff)
;
p=r/s;
}
I don't understand what the p value does and from this how do you get the random number your looking for in the range low to high?

4
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by __avd
0

well the values s, cutoff and p are are not being declared. secondly what is the function rng()? also where are you using high and low?

0

Those variables are declared I just put the puedocode in my post. The namespace is declared already and the rng() is the range of numbers it can be in

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.