.\" -*- coding: UTF-8 -*- '\" t .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) .\" .\" SPDX-License-Identifier: Linux-man-pages-copyleft .\" .\" 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 "10 février 2023" "Pages du manuel de Linux 6.03" .SH NOM random, srandom, initstate, setstate \- Générateur de nombres aléatoires .SH BIBLIOTHÈQUE Bibliothèque C standard (\fIlibc\fP, \fI\-lc\fP) .SH SYNOPSIS .nf \fB#include \fP .PP \fBlong random(void);\fP \fBvoid srandom(unsigned int \fP\fIgraine\fP\fB);\fP .PP \fBchar *initstate(unsigned int \fP\fIseed\fP\fB, char \fP\fIstate\fP\fB[.\fP\fIn\fP\fB], size_t \fP\fIn\fP\fB);\fP \fBchar *setstate(char *\fP\fIstate\fP\fB);\fP .fi .PP .RS -4 Exigences de macros de test de fonctionnalités pour la glibc (consulter \fBfeature_test_macros\fP(7))\ : .RE .PP \fBrandom\fP(), \fBsrandom\fP(), \fBinitstate\fP(), \fBsetstate\fP()\ : .nf .\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED _XOPEN_SOURCE >= 500 || /* glibc >= 2.19: */ _DEFAULT_SOURCE || /* glibc <= 2.19: */ _SVID_SOURCE || _BSD_SOURCE .fi .SH DESCRIPTION The \fBrandom\fP() function uses a nonlinear additive feedback random number generator employing a default table of size 31 long integers to return successive pseudo\-random numbers in the range from 0 to 2\[ha]31\ \-\ 1. The period of this random number generator is very large, approximately \fI16\ *\ ((2\[ha]31)\ \-\ 1)\fP. .PP La fonction \fBsrandom\fP() utilise son argument comme «\ graine\ » pour engendrer une nouvelle séquence de nombres 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 \fB1\fP. .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\[em]the 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'états \fIétat\fP est alors utilisée comme générateur de nombres aléatoires jusqu'au prochain appel de \fBinitstate\fP() ou \fBsetstate\fP(). \fIétat\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" The \fBrandom\fP() function returns a value between 0 and \fI(2\[ha]31)\ \-\ 1\fP. The \fBsrandom\fP() function returns no value. .PP La fonction \fBinitstate\fP() renvoie un pointeur sur la table d'états précédente. En cas d'échec, elle renvoie \fBNULL\fP et \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, \fBNULL\fP est renvoyé et \fIerrno\fP contient le code d'erreur. .SH ERREURS .TP \fBEINVAL\fP Le paramètre \fIétat\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). .ad l .nh .TS allbox; lbx lb lb l l l. Interface Attribut Valeur T{ \fBrandom\fP(), \fBsrandom\fP(), \fBinitstate\fP(), \fBsetstate\fP() T} Sécurité des threads MT\-Safe .TE .hy .ad .sp 1 .SH STANDARDS POSIX.1\-2001, POSIX.1\-2008, 4.3BSD. .SH NOTES La fonction \fBrandom\fP() ne doit pas être utilisée dans des programmes multithreadés où le comportement doit être reproductible. Utilisez \fBrandom_r\fP(3) dans ce cas. .PP La génération de nombres aléatoires est un sujet complexe. \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, 3e\ éd.) fournit une excellente discussion sur les problèmes pratiques de génération de noms aléatoires dans le chapitre\ 7 (Random Numbers). .PP Pour une discussion plus théorique, qui aborde également en profondeur d'autres domaines, voir le chapitre\ 3 (Random Numbers) du livre de Donald E. Knuth \fIThe Art of Computer Programming\fP, volume\ 2 (Seminumerical Algorithms), 2e\ éd.\ ; 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 \fBNULL\fP. .SH "VOIR AUSSI" \fBgetrandom\fP(2), \fBdrand48\fP(3), \fBrand\fP(3), \fBrandom_r\fP(3), \fBsrand\fP(3) .PP .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 , David Prévot et bubu . .PP 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. .PP 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 .