4-stable and C rand()?

Kris Kennaway kris at obsecurity.org
Mon Apr 7 15:58:41 PDT 2003


On Mon, Apr 07, 2003 at 03:16:03PM +0100, David Malone wrote:

> Rather than use rand()%32 you might want to use something like
> (rand()+RAND_MAX/64)/(RAND_MAX/32) - using the high order bits means
> that you are not effectively reducing the side of the state space.

Or use a better PRNG like arc4random().

Kris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-stable/attachments/20030407/18634c30/attachment.bin


More information about the freebsd-stable mailing list