ToExponential





' Il metodo toExponential ()

'toExponential() ritorna una stringa, con un numero arrotondato e scritto usando la notazione esponenziale.


'Un parametro definisce il numero di caratteri dietro il punto decimale:


'Esempio

'var x = 9.656;

'x.toExponential(2); // returns 9.66e+0

'x.toExponential(4); // returns 9.6560e+0

'x.toExponential(6); // returns 9.656000e+0


https://www.w3schools.com/js/tryit.asp?filename=tryjs_number_toexponential


<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Number Methods</h2>

<p>The toExponential() method returns a string, with the number rounded and written using exponential notation.</p>

<p>An optional parameter defines the number of digits behind the decimal point.</p>

<p id="demo"></p>

<script>
var x = 9.656;
document.getElementById("demo").innerHTML =
x.toExponential() + "<br>" +
x.toExponential(2) + "<br>" +
x.toExponential(4) + "<br>" +
x.toExponential(6);
</script>

</body>
</html>











( toexponential.html )- by Paolo Puglisi - Modifica del 17/12/2023