In article <1112600410.38806c8dd45da8a3a4a37b6ab0a2ed61@teran ews>,
Martin Magnusson <martin@-xx-blecket-xx-.org> wrote:
Profil1 wrote: float random_value = rand()/RAND_MAX;
To be sure that you actually get a float, and not just something rounded
to 0 or 1, you could write
float random_value = static_cast<float>(rand())/RAND_MAX;
While this is common advice, and often works well in practice, this
can cause serious numerical biases. For instance, if RAND_MAX=65536
and you're selecting from 100,000 elements at random, you'll never
select some of the elements.
boost has done quite a bit to make these issues. See:
<http://www.boost.org/libs/random/>
--
Mark Ping
em****@soda.CSUA.Berkeley.EDU