JavaScript Math.fround()
Exemple
let a = Math.fround(2.60);
let b = Math.fround(2.50);
let c = Math.fround(2.49);
let d = Math.fround(-2.60);
let e = Math.fround(-2.50);
let f = Math.fround(-2.49);
Définition et utilisation
La méthode Math.fround() renvoie la représentation flottante la plus proche (simple précision 32 bits) d'un nombre.
Prise en charge du navigateur
Math.fround()
est une fonctionnalité ECMAScript6 (ES6).
ES6 (JavaScript 2015) est pris en charge dans tous les navigateurs modernes :
Chrome | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes |
Math.fround()
n'est pas pris en charge dans Internet Explorer 11 (ou version antérieure).
Syntaxe
Math.fround(x)
Paramètres
Parameter | Description |
---|---|
x | Required. A number |
Valeur de retour
La représentation flottante simple précision 32 bits la plus proche du nombre. |