Sample Example:
var amount = 100;
alert(amount); // output: 100
How can i achieve output as 100.0
?
Sample Example:
var amount = 100;
alert(amount); // output: 100
How can i achieve output as 100.0
?
use .toFixed(int)
:
var amount = 100;
document.querySelector('pre').innerHTML = parseFloat(amount).toFixed(1);
<pre></pre>
var amount = 100;
alert(amount.toFixed(1)); // output: 100.0
alert(amount.toFixed(2)); // output: 100.00
alert(amount.toFixed(3)); // output: 100.000
var amount = 100;
alert(amount); // output: 100
alert(amount.toFixed(1)); // output: 100.0
alert(amount.toFixed(2)); // output: 100.00
alert(amount.toFixed(3)); // output: 100.000
https://www.w3schools.com/jsref/jsref_tofixed.asp
**number.toFixed(x)**
where number is what you intend to convert to double, and X is the precision you want to set.