Re: Random number (1,2,3)



pete wrote:
pete wrote:
*** T. Winter wrote:
In article <1165455688.545731.67390@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
"rhitx" <julimarjane@xxxxxxxxx> writes:
> I'm trying create a random number generator,
> which will generate either number 1, 2, 3.

> no_goal = (rand_Number % 3);

The low order bits are highly non-random.

They may be true for some PRGs, certainly not for all, making the statement misleading.

Even if the lower order bits were constant,
I don't see how that would be deleterious to a {1,2,3} prng
which uses a remainder operator with a right operand of 3.

Good point! Since n is relatively prime to (1 << intbits), a few non-random low bits shouldn't have an effect.

I think this might express the idea better, since in this one, the three order bits are actually constant
in the object called "three_lower_order_bits_are_constant".

/* BEGIN new.c */

Nice demo.

--
Thad
.