Changeset View
Changeset View
Standalone View
Standalone View
head/lib/libc/stdlib/random.3
Show All 22 Lines | |||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
.\" SUCH DAMAGE. | .\" SUCH DAMAGE. | ||||
.\" | .\" | ||||
.\" @(#)random.3 8.1 (Berkeley) 6/4/93 | .\" @(#)random.3 8.1 (Berkeley) 6/4/93 | ||||
.\" $FreeBSD$ | .\" $FreeBSD$ | ||||
.\" | .\" | ||||
.Dd January 20, 2020 | .Dd February 1, 2020 | ||||
.Dt RANDOM 3 | .Dt RANDOM 3 | ||||
.Os | .Os | ||||
.Sh NAME | .Sh NAME | ||||
.Nm random , | .Nm random , | ||||
.Nm srandom , | .Nm srandom , | ||||
.Nm srandomdev , | .Nm srandomdev , | ||||
.Nm initstate , | .Nm initstate , | ||||
.Nm setstate | .Nm setstate | ||||
Show All 29 Lines | |||||
.if t 2\u\s731\s10\d\(mi1. | .if t 2\u\s731\s10\d\(mi1. | ||||
.if n (2**31)\(mi1. | .if n (2**31)\(mi1. | ||||
The period of this random number generator is very large, approximately | The period of this random number generator is very large, approximately | ||||
.if t 16\(mu(2\u\s731\s10\d\(mi1). | .if t 16\(mu(2\u\s731\s10\d\(mi1). | ||||
.if n 16*((2**31)\(mi1). | .if n 16*((2**31)\(mi1). | ||||
.Pp | .Pp | ||||
If initialized with less than 32 bytes of state, | If initialized with less than 32 bytes of state, | ||||
.Fn random | .Fn random | ||||
uses the same poor-quality Park-Miller LCG as | uses the poor-quality 32-bit Park-Miller LCG. | ||||
.Xr rand 3 . | |||||
.Pp | .Pp | ||||
The | The | ||||
.Fn random | .Fn random | ||||
and | and | ||||
.Fn srandom | .Fn srandom | ||||
functions are analagous to | functions are analagous to | ||||
.Xr rand 3 | .Xr rand 3 | ||||
and | and | ||||
.Xr srand 3 . | .Xr srand 3 . | ||||
The difference is that | |||||
.Xr rand 3 | |||||
is a worse pseudo-random number generator. | |||||
.Pp | .Pp | ||||
Like | Like | ||||
.Xr rand 3 , | .Xr rand 3 , | ||||
.Fn random | .Fn random | ||||
is implicitly initialized as if | is implicitly initialized as if | ||||
.Fn srandom "1" | .Fn srandom "1" | ||||
had been invoked explicitly. | had been invoked explicitly. | ||||
.Pp | .Pp | ||||
▲ Show 20 Lines • Show All 84 Lines • Show Last 20 Lines |