Latest web development tutorials

méthode JavaScript de round ()

Math Object Reference JavaScript Object Math

Exemples

méthode round () à un nombre arrondi à l'entier le plus proche:

Math.round(2.5);

sortie:

3

Essayez »

Définition et utilisation

méthode round () à un nombre arrondi à l'entier le plus proche.

Note: 2.49 arrondi 2, 2,5 arrondi 3.


support du navigateur

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Tous les principaux navigateurs prennent en charge round () méthode


grammaire

Math.round( x )

Paramètre Valeur

参数 描述
x 必需。必须是数字。

Valeur de retour

类型 描述
Number 最接近的整数。

détails techniques

Version JavaScript: 1.0


D'autres exemples

Exemples

Les différents nombres arrondis à l'entier le plus proche:

var a=Math.round(2.60);
var b=Math.round(2.50);
var c=Math.round(2.49);
var d=Math.round(-2.60);
var e=Math.round(-2.50);
var f=Math.round(-2.49);

a, b, c, d, e et f du moteur:

3
3
2
-3
-2
-2

Essayez »


Math Object Reference JavaScript Object Math