|
NAMErand , srand ,
rand_r —
bad random number generator
LIBRARYStandard C Library (libc, -lc)SYNOPSIS#include <stdlib.h>
void
int
int
DESCRIPTIONThe functions described in this manual page are not
cryptographically secure. Applications which require unpredictable random
numbers should use
arc4random(3)
instead.
The The In FreeBSD 13,
IMPLEMENTATION NOTESSince FreeBSD 13,rand () is
implemented with the same generator as
random(3),
so the low-order bits should no longer be significantly worse than the
high-order bits.
SEE ALSOarc4random(3), random(3), random(4)STANDARDSTherand () and srand () functions
conform to ISO/IEC 9899:1990
(“ISO C90”).
The CAVEATSPrior to FreeBSD 13,rand () used
the historical Park-Miller generator with 32 bits of state and produced poor
quality output, especially in the lower bits. rand ()
in earlier versions of FreeBSD, as well as other
standards-conforming implementations, may continue to produce poor quality
output.
These functions should not be used in portable applications that want a high quality or high performance pseudorandom number generator. One possible replacement, random(3), is portable to Linux — but it is not especially fast, nor standardized. If broader portability or better performance is desired, any of the widely available and permissively licensed SFC64/32, JSF64/32, PCG64/32, or SplitMix64 algorithm implementations may be embedded in your application. These algorithms have the benefit of requiring less space than random(3) and being quite fast (in header inline implementations).
Visit the GSP FreeBSD Man Page Interface. |