Anteprima
Vedrai una selezione di 1 pagina su 2
Sistemi operativi - Syscall rand Pag. 1
1 su 2
D/illustrazione/soddisfatti o rimborsati
Disdici quando
vuoi
Acquista con carta
o PayPal
Scarica i documenti
tutte le volte che vuoi
Estratto del documento

rand, rand_r - pseudo-random number generator

The rand() function computes a sequence of pseudo-random integers in the range 0 to 32RAND_MAX with a period of at least 2.

The srand() function uses the argument as a seed for a new sequence of pseudo-random numbers to be returned by subsequent calls to rand(). If srand() is then called with the same seed value, the sequence of pseudo-random numbers will be repeated. If rand() is called before any calls to srand() are made, the same sequence will be generated as when srand() is first called with a seed value of 1.

The implementation will behave as if no function defined in this document calls rand() or srand().

The rand() interface need not be reentrant.

The rand_r() function

The rand() function computes a sequence of pseudo-random integers in the range 0 to {RAND_MAX}. (The value of the {RAND_MAX} macro will be at least 32767.)

If rand_r() is called with the same initial value for the object pointed to by seed and that object is not modified between successive returns and calls to rand_r(), the same sequence shall be generated.

RETURN VALUE

The rand() function returns the next pseudo-random number in the sequence. The srand() function returns no value.

The rand_r() function returns a pseudo-random integer.

ERRORS

No errors are defined.

EXAMPLES

None.

1 di 2 10/06/2010 16:19

Dettagli
Publisher
A.A. 2012-2013
2 pagine
SSD Scienze matematiche e informatiche INF/01 Informatica

I contenuti di questa pagina costituiscono rielaborazioni personali del Publisher N. A. di informazioni apprese con la frequenza delle lezioni di Sistemi operativi e studio autonomo di eventuali libri di riferimento in preparazione dell'esame finale o della tesi. Non devono intendersi come materiale ufficiale dell'università Università degli studi di Napoli Federico II o del prof Cotroneo Domenico.