no equal distribution here, neither (@ lostclimate).
another problem is that when you have a look at the output of rand5 bit-wise you'll notice that the least significant bit is set 60% of time, bit 2 and 3 both 40% of time. for our rand7 we need (beginning at the least significant bit) p0=4/7, p1=4/7, p2=4/7. now try combining the first probabilities to retreive the second ones... you'll notice that it's impossible since x/7 is a prime fraction which can't be the result of a multiplication without another seven-fraction (i don't know the word in english, i hope you get my point). (in fact, not with an and, an or or an xor, since all outcome-probabilities are just additions or multiplications).
so forget about combining the results of rand5 bitwise.
i tend to think that if you want no predictability (wrong in my example) and a perfectly equal distribution you'll need at least one if-branch.
joey.
Last edited by Joey; 10/23/07 09:29.