For example:
10 is formatted as 10.00
1.1 is formatted as 1.10
2.21 is formatted as 2.21
No other circumstances
There is BigDecimal in java that can be used. Is there anything similar in js?
曾经蜡笔没有小新2017-05-18 10:58:09
const printf = require('printf')
printf('%.2f', 10) //10.00
(10).toFixed(2) //10.00
習慣沉默2017-05-18 10:58:09
Use toFixed (number of decimal places)
var a=1;
a.toFixed(2) //"1.00"
typeof a // "number"