function toDecimal2(x) {
var f = parseFloat(x);
if (isNaN(f)) {
return false;
}
var f = Math.round(x*100)/100;
var s = f.toString();
var rs = s.indexOf(‘.‘);
if (rs < 0) {
rs = s.length;
s += ‘.‘;
}
while (s.length <= rs + 2) {
s += ‘0‘;
}
return s;
}
//-------调用
var val;
val=obj[i].value.replace(‘[‘,‘‘);
val=val.replace(‘]‘,‘‘);
var arr= val.split(‘,‘);
var v1 = toDecimal2(arr[0]);
时间: 2024-10-12 20:12:42