programming-examples/js/Math/Round a number to a specified number of digits and strip extra zeros.js
2019-11-15 12:59:38 +01:00

10 lines
262 B
JavaScript

//var a = -1.1230000;
//var a = 0.0000009999999;
//var a = 1.000000000;
//var a = -4.55555;
//var a = 5.0001000;
var a = 1.1234000;
var result = parseFloat(a.toFixed(4));
console.log(result);