Issue
I am trying to get the right format for my operations, I want an exponential but I would like to limit the number of displayed decimals to only 2, like for example 1.13E+2 how can I do this work? Thanks in advance
row.querySelector(".one").value = (C1 * fuel).toExponential();
row.querySelector(".two").value = (C2 * fuel).toExponential();
row.querySelector(".three").value = (C3 * fuel).toExponential();
Solution
You can use toFixed, https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed
row.querySelector(".one").value = Number.parseFloat((C1 * fuel).toExponential(2));
Answered By - Frank Dax Answer Checked By - Clifford M. (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.