var changeTwoDecimal_f= function (floatvar){
var f_x = parseFloat (floatvar);
if (isNaN(f_x)){
return '0.00';
}
var f_x = Math.round(f_x*100)/100;
var s_x = f_x.toString();
var pos_decimal = s_x.indexOf('.');
if (pos_decimal < 0){
pos_decimal = s_x.length;
s_x = '.';
}
while (s_x.length <= pos_decimal 2){
s_x = '0';
}
return s_x;
}
Rounding function provided by js:
js rounding function toFixed( ), the parameter inside is the number of decimal places to retain.
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn