aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/javascript/reference/global_objects/math/random/index.html
diff options
context:
space:
mode:
authorMasahiro FUJIMOTO <mfujimot@gmail.com>2021-09-04 00:46:12 +0900
committerMasahiro FUJIMOTO <mfujimot@gmail.com>2021-09-04 00:46:12 +0900
commitfe6f6abf2b7c497bf1f97f73a82dde7cf48eb79f (patch)
tree51b7edfc370236684a203f4e69ae67bb7d24b549 /files/fr/web/javascript/reference/global_objects/math/random/index.html
parent04ea4edc83cc12142ed151bbea2c65cffc8e76f6 (diff)
parenteeb07fe338cdc90092841d717919f46f9d9e3ff9 (diff)
downloadtranslated-content-fe6f6abf2b7c497bf1f97f73a82dde7cf48eb79f.tar.gz
translated-content-fe6f6abf2b7c497bf1f97f73a82dde7cf48eb79f.tar.bz2
translated-content-fe6f6abf2b7c497bf1f97f73a82dde7cf48eb79f.zip
Merge branch 'main' into 20210818-Glossary/Type
Diffstat (limited to 'files/fr/web/javascript/reference/global_objects/math/random/index.html')
-rw-r--r--files/fr/web/javascript/reference/global_objects/math/random/index.html113
1 files changed, 0 insertions, 113 deletions
diff --git a/files/fr/web/javascript/reference/global_objects/math/random/index.html b/files/fr/web/javascript/reference/global_objects/math/random/index.html
deleted file mode 100644
index c5b3df93df..0000000000
--- a/files/fr/web/javascript/reference/global_objects/math/random/index.html
+++ /dev/null
@@ -1,113 +0,0 @@
----
-title: Math.random()
-slug: Web/JavaScript/Reference/Global_Objects/Math/random
-tags:
- - JavaScript
- - Math
- - Méthode
- - Reference
-translation_of: Web/JavaScript/Reference/Global_Objects/Math/random
-original_slug: Web/JavaScript/Reference/Objets_globaux/Math/random
----
-<div>{{JSRef}}</div>
-
-<p>La fonction <code><strong>Math.random()</strong></code> renvoie un nombre flottant pseudo-aléatoire compris dans l'intervalle <code>[0, 1[</code> (ce qui signifie que 0 est compris dans l'intervalle mais que 1 en est exclu) selon une distribution approximativement uniforme sur cet intervalle. Ce nombre peut ensuite être multiplié afin de couvrir un autre intervalle. La graine (<em>seed</em>) du générateur est choisie par l'algorithme et ne peut pas être choisie ou réinitialisée par l'utilisateur.</p>
-
-<div>{{EmbedInteractiveExample("pages/js/math-random.html")}}</div>
-
-<div class="note">
-<p><strong>Note :</strong> <code>Math.random()</code> <strong>ne fournit pas</strong> de nombres aléatoires propres à une cryptographie sécurisée. Les résultats de cette méthode ne doivent pas être utilisées dans des applications liées à la sécurité. À la place, on préfèrera utiliser l'API Web Crypto et plus précisément la méthode {{domxref("RandomSource.getRandomValues()", "window.crypto.getRandomValues()")}}.</p>
-</div>
-
-<h2 id="Syntaxe">Syntaxe</h2>
-
-<pre class="syntaxbox notranslate">Math.random()</pre>
-
-<h3 id="Valeur_de_retour">Valeur de retour</h3>
-
-<p>Un nombre flottant pseudo-aléatoire, généré entre 0 (inclus) et 1 (exclu)</p>
-
-<h2 id="Exemples">Exemples</h2>
-
-<p>En JavaScript, les nombres sont représentés comme des nombres flottants selon la norme IEEE 754 et les arrondis sont pris aux plus près. Aussi, les intervalles revendiqués par les fonctions ci-après (en dehors de <code>Math.random()</code>) ne sont pas théoriquement et précisément exacts. Si on utilise des bornes supérieures très grande (2^53 ou plus), il est alors possible, dans de très rares cas, d'obtenir la borne supérieure comme résultat alors que celle-ci devrait être exclue de l'intervalle.</p>
-
-<h3 id="Obtenir_un_nombre_aléatoire_entre_0_et_1">Obtenir un nombre aléatoire entre 0 et 1</h3>
-
-<pre class="brush: js notranslate">// On renvoie un nombre aléatoire entre 0 (inclus) et 1 (exclus)
-function getRandom() {
- return Math.random();
-}</pre>
-
-<h3 id="Obtenir_un_nombre_aléatoire_dans_un_intervalle">Obtenir un nombre aléatoire dans un intervalle</h3>
-
-<pre class="brush: js notranslate">// On renvoie un nombre aléatoire entre une valeur min (incluse)
-// et une valeur max (exclue)
-function getRandomArbitrary(min, max) {
- return Math.random() * (max - min) + min;
-}</pre>
-
-<h3 id="Obtenir_un_entier_aléatoire_dans_un_intervalle_ouvert_à_droite">Obtenir un entier aléatoire dans un intervalle ouvert à droite</h3>
-
-<pre class="brush: js notranslate">// On renvoie un entier aléatoire entre une valeur min (incluse)
-// et une valeur max (exclue).
-// Attention : si on utilisait Math.round(), on aurait une distribution
-// non uniforme !
-function getRandomInt(min, max) {
- min = Math.ceil(min);
- max = Math.floor(max);
- return Math.floor(Math.random() * (max - min)) + min;
-}
-</pre>
-
-<div class="warning">
-<p><strong>Attention :</strong> Utiliser <code>Math.round()</code> entraînerait une distribution non-uniforme et réduirait le caractère aléatoire de la méthode.</p>
-</div>
-
-<h3 id="Obtenir_un_entier_aléatoire_dans_un_intervalle_fermé">Obtenir un entier aléatoire dans un intervalle fermé</h3>
-
-<pre class="brush: js notranslate">// On renvoie un entier aléatoire entre une valeur min (incluse)
-// et une valeur max (incluse).
-// Attention : si on utilisait Math.round(), on aurait une distribution
-// non uniforme !
-function getRandomIntInclusive(min, max) {
- min = Math.ceil(min);
- max = Math.floor(max);
- return Math.floor(Math.random() * (max - min +1)) + min;
-}
-</pre>
-
-<h2 id="Spécifications">Spécifications</h2>
-
-<table class="standard-table">
- <tbody>
- <tr>
- <th scope="col">Spécification</th>
- <th scope="col">État</th>
- <th scope="col">Commentaires</th>
- </tr>
- <tr>
- <td>{{SpecName('ES1')}}</td>
- <td>{{Spec2('ES1')}}</td>
- <td>Définition initiale. Implémentée avec JavaScript 1.0 (UNIX) et 1.1 (toutes plateformes).</td>
- </tr>
- <tr>
- <td>{{SpecName('ES5.1', '#sec-15.8.2.14', 'Math.random')}}</td>
- <td>{{Spec2('ES5.1')}}</td>
- <td></td>
- </tr>
- <tr>
- <td>{{SpecName('ES6', '#sec-math.random', 'Math.random')}}</td>
- <td>{{Spec2('ES6')}}</td>
- <td></td>
- </tr>
- <tr>
- <td>{{SpecName('ESDraft', '#sec-math.random', 'Math.random')}}</td>
- <td>{{Spec2('ESDraft')}}</td>
- <td></td>
- </tr>
- </tbody>
-</table>
-
-<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2>
-
-<p>{{Compat("javascript.builtins.Math.random")}}</p>