State the fact that the range is twice the traditional RAND_MAX.

Add an EXAMPLES section.

PR:		48493
Submitted by:	Paul Herman <pherman@frenchfries.net> (original version)
This commit is contained in:
Tom Rhodes 2003-05-01 19:09:16 +00:00
parent d05090827f
commit 7b98ad3005

View File

@ -57,7 +57,13 @@ The S-Boxes
can be in about
.if t 2\u\s71700\s10\d
.if n (2**1700)
states.
states. The
.Fn arc4random
function returns pseudo-random numbers in the range of 0 to
.if t 2\u\s731\s10\d\(mi1,
.if n (2**31)\(mi1,
and therefore has twice the range of
.Dv RAND_MAX .
.Pp
The
.Fn arc4random_stir
@ -73,6 +79,15 @@ before using
since
.Fn arc4random
automatically initializes itself.
.Sh EXAMPLES
The following produces a drop-in replacement for the traditional
.Fn rand
and
.Fn random
functions using
.Fn arc4random :
.Pp
.Dv #define Fn foo4random ( Fn arc4random Ft % ((unsigned)RAND_MAX + 1))
.Sh SEE ALSO
.Xr rand 3 ,
.Xr random 3 ,