Actually, when you think about it rand() * rand()
is less random than rand()
. Here's why.
Essentially, there are the same number of odd numbers as even numbers. And saying that 0.04325 is odd, and like 0.388 is even, and 0.4 is even, and 0.15 is odd,
That means that rand()
has a equal chance of being an even or odd decimal.
On the other hand, rand() * rand()
has it's odds stacked a bit differently.Lets say:
double a = rand();double b = rand();double c = a * b;
a
and b
both have a 50% precent chance of being even or odd. Knowing that
- even * even = even
- even * odd = even
- odd * odd = odd
- odd * even = even
means that there a 75% chance that c
is even, while only a 25% chance it's odd, making the value of rand() * rand()
more predictable than rand()
, therefore less random.