Réf. : Re: [LC++]Random numbers

Grzegorz Mazur mazur at chemia.uj.edu.pl
Sun Sep 2 05:56:26 UTC 2001


On Fri, 31 Aug 2001, David Filion wrote:

> If you know your going to be running on a Linux system, you could read from
> /dev/urandom.

Not really if what you want are _pseudorandom_ numbers. The /dev/urandom
tries hard to deliver truly random numbers, gathering entropy from real
world. This is invaluable when you do cryptography, but what you really 
need for majority of calculations is a pseudorandom generator.

> You might also want to look at lrand48(). (I'm not sure if it exists in c++
> though).

If it exists in a C library, you can usually use it from C++. But I'd not
recommend using lrand48, as it's deprecated. If you really have, use
rand[om] instead. And before you use it, read my previous mail in this
thread, just to be aware of the pitfalls.


More information about the tuxCPProgramming mailing list