.\" -*- coding: UTF-8 -*- .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\" References consulted: .\" Linux libc source code .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) .\" 386BSD man pages .\" Modified Sun Mar 28 00:25:51 1993, David Metcalfe .\" Modified Sat Jul 24 18:13:39 1993 by Rik Faith (faith@cs.unc.edu) .\" Modified Sun Aug 20 21:47:07 2000, aeb .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH RANDOM 3 "6 mars 2019" GNU "Manuel du programmeur Linux" .SH NOM random, srandom, initstate, setstate \- Générateur de nombres aléatoires .SH SYNOPSIS .nf \fB#include \fP .PP \fBlong int random(void);\fP .PP \fBvoid srandom(unsigned int \fP\fIseed\fP\fB);\fP .PP \fBchar *initstate(unsigned int \fP\fIseed\fP\fB, char *\fP\fIstate\fP\fB, size_t \fP\fIn\fP\fB);\fP .PP \fBchar *setstate(char *\fP\fIstate\fP\fB);\fP .fi .PP .in -4n Exigences de macros de test de fonctionnalités pour la glibc (consulter \fBfeature_test_macros\fP(7))\ : .in .PP .ad l \fBrandom\fP(), \fBsrandom\fP(), \fBinitstate\fP(), \fBsetstate\fP()\ : .RS 4 .\" || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED _XOPEN_SOURCE\ >=\ 500 || /* Glibc since 2.19: */ _DEFAULT_SOURCE || /* Glibc versions <= 2.19: */ _SVID_SOURCE || _BSD_SOURCE .RE .ad .SH DESCRIPTION La fonction \fBrandom\fP() utilise un générateur de nombre aléatoire non linéaire («\ non\-linear additive feedback random number generator\ ») utilisant une table par défaut de 31 entiers longs pour renvoyer successivement des nombres pseudoaléatoires entre 0 et \fBRAND_MAX\fP. La période de ce générateur est très grande, approximativement \fI16\ *\ ((2^31)\ \-\ 1)\fP. .PP La fonction \fBsrandom\fP() utilise son argument comme «\ graine\ » pour engendrer une nouvelle séquence de nombre pseudoaléatoires qui seront fournis lors des appels à \fBrandom\fP(). Ces séquences sont reproductibles en invoquant \fBsrandom\fP() avec la même graine. Si aucune graine n'est fournie, La fonction \fBrandom\fP() utilise automatiquement une graine originale de valeur 1. .PP The \fBinitstate\fP() function allows a state array \fIstate\fP to be initialized for use by \fBrandom\fP(). The size of the state array \fIn\fP is used by \fBinitstate\fP() to decide how sophisticated a random number generator it should use\(emthe larger the state array, the better the random numbers will be. Current "optimal" values for the size of the state array \fIn\fP are 8, 32, 64, 128, and 256 bytes; other amounts will be rounded down to the nearest known amount. Using less than 8 bytes results in an error. \fIseed\fP is the seed for the initialization, which specifies a starting point for the random number sequence, and provides for restarting at the same point. .PP La fonction \fBsetstate\fP() modifie la table d'états utilisée par la fonction \fBrandom\fP(). La table d'état \fIstate\fP est alors utilisée comme générateur de nombres aléatoires jusqu'au prochain appel de \fBinitstate\fP() ou \fBsetstate\fP(). \fIstate\fP doit d'abord être initialisée avec \fBinitstate\fP() ou être le résultat d'un appel précédent à \fBsetstate\fP() .SH "VALEUR RENVOYÉE" La fonction \fBrandom\fP() renvoie une valeur entre 0 et \fBRAND_MAX\fP. La fonction \fBsrandom\fP() ne renvoie pas de valeur. .PP La fonction \fBinitstate\fP() renvoie un pointeur sur la table d'états précédente. En cas d'échec, \fIerrno\fP contient le code d'erreur. .PP La fonction \fBsetstate\fP() renvoie un pointeur sur la table d'états précédente. En cas d'échec, NULL est renvoyé et \fIerrno\fP contient le code d'erreur. .SH ERREURS .TP \fBEINVAL\fP Le paramètre \fIstate\fP de \fBsetstate\fP() était NULL. .TP \fBEINVAL\fP Une table d'états de moins de 8\ octets a été fournie à \fBinitstate\fP(). .SH ATTRIBUTS Pour une explication des termes utilisés dans cette section, consulter \fBattributes\fP(7). .TS allbox; lbw23 lb lb l l l. Interface Attribut Valeur T{ \fBrandom\fP(), \fBsrandom\fP(), .br \fBinitstate\fP(), \fBsetstate\fP() T} Sécurité des threads MT\-Safe .TE .SH CONFORMITÉ POSIX.1\-2001, POSIX.1\-2008, 4.3BSD. .SH NOTES The \fBrandom\fP() function should not be used in multithreaded programs where reproducible behavior is required. Use \fBrandom_r\fP(3) for that purpose. .PP Random\-number generation is a complex topic. \fINumerical Recipes in C: The Art of Scientific Computing\fP (William H.\& Press, Brian P.\& Flannery, Saul A.\& Teukolsky, William T.\& Vetterling; New York: Cambridge University Press, 2007, 3rd ed.) provides an excellent discussion of practical random\-number generation issues in Chapter 7 (Random Numbers). .PP For a more theoretical discussion which also covers many practical issues in depth, see Chapter 3 (Random Numbers) in Donald E.\& Knuth's \fIThe Art of Computer Programming\fP, volume 2 (Seminumerical Algorithms), 2nd ed.; Reading, Massachusetts: Addison\-Wesley Publishing Company, 1981. .SH BOGUES .\" http://sourceware.org/bugzilla/show_bug.cgi?id=15380 D'après POSIX, \fBinitstate\fP() devrait renvoyer NULL en cas d'erreur. Dans la mise en œuvre de la glibc, \fIerrno\fP est renseigné en cas d'erreur comme spécifié, mais la fonction ne renvoie pas NULL .SH "VOIR AUSSI" \fBgetrandom\fP(2), \fBdrand48\fP(3), \fBrand\fP(3), \fBrandom_r\fP(3), \fBsrand\fP(3) .SH COLOPHON Cette page fait partie de la publication\ 5.04 du projet \fIman\-pages\fP Linux. Une description du projet et des instructions pour signaler des anomalies et la dernière version de cette page peuvent être trouvées à l'adresse \%https://www.kernel.org/doc/man\-pages/. .SH TRADUCTION La traduction française de cette page de manuel a été créée par Christophe Blaess , Stéphan Rafin , Thierry Vignaud , François Micaux, Alain Portal , Jean-Philippe Guérard , Jean-Luc Coulon (f5ibh) , Julien Cristau , Thomas Huriaux , Nicolas François , Florentin Duneau , Simon Paillard , Denis Barbier et David Prévot . Cette traduction est une documentation libre ; veuillez vous reporter à la .UR https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License version 3 .UE concernant les conditions de copie et de distribution. Il n'y a aucune RESPONSABILITÉ LÉGALE. Si vous découvrez un bogue dans la traduction de cette page de manuel, veuillez envoyer un message à .MT debian-l10n-french@lists.debian.org .ME .