From da78a9e329e272dedb2400b79a3bdeebff387d47 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:17 -0500 Subject: initial commit --- .../reference/global_objects/math/round/index.html | 100 +++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 files/it/web/javascript/reference/global_objects/math/round/index.html (limited to 'files/it/web/javascript/reference/global_objects/math/round') diff --git a/files/it/web/javascript/reference/global_objects/math/round/index.html b/files/it/web/javascript/reference/global_objects/math/round/index.html new file mode 100644 index 0000000000..4b20fb4a42 --- /dev/null +++ b/files/it/web/javascript/reference/global_objects/math/round/index.html @@ -0,0 +1,100 @@ +--- +title: Math.round() +slug: Web/JavaScript/Reference/Global_Objects/Math/round +translation_of: Web/JavaScript/Reference/Global_Objects/Math/round +--- +
{{JSRef}}
+ +

La funzione Math.round() restituisce il valore di un numero approssimato all'intero ad esso più vicino.

+ +
{{EmbedInteractiveExample("pages/js/math-round.html")}}
+ + + +

Sintassi

+ +
Math.round(x)
+ +

Parametri

+ +
+
x
+
Un numero.
+
+ +

Valore restituito

+ +

Il valore del numero dato approssimato all'intero più vicino.

+ +

Descrizione

+ +

Se la parte frazionale del numero è maggiore di 0.5, l'argomento (x) è approssimato all'intero successivo con il valore assoluto più elevato. Se è inferiore di 0.5, l'argomento è approssimato all'intero con il valore assoluto più basso.  Se la parte frazionale è esattamente 0.5, l'argomento è approssimato all'intero successivo nella direzione di +∞.  Si noti che questo è diverso da quanto accade nelle funzioni round() di molti altri linguaggi, che spesso invece approssimano questo caso all'intero successivo più lontano da zero, (dando un risultato diverso nel caso dei numeri negativi con una parte frazionale di esattamente 0.5).

+ +

Poiché round() è un metodo statico di Math, lo si usa sempre come Math.round(), piuttosto che come un metodo di un Oggetto Math appositamente creato (Math non ha un costruttore).

+ +

Esempi

+ +
Math.round( 20.49); //  20
+Math.round( 20.5 ); //  21
+Math.round( 42   ); //  42
+Math.round(-20.5 ); // -20
+Math.round(-20.51); // -21
+
+ +

 

+ +

Specifications

+ +

 

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.8.2.15', 'Math.round')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-math.round', 'Math.round')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-math.round', 'Math.round')}}{{Spec2('ESDraft')}} 
+ +

Browser compatibility

+ + + +

{{Compat("javascript.builtins.Math.round")}}

+ +

 

+ +

See also

+ +

 

+ + -- cgit v1.2.3-54-g00ecf