<body>
<script>
function Mul(n1,n2){
var m=0,s1=n1.toString(),s2=n2.toString();
try{m+=s1.split(".")[1].length}catch(e){}
try{m+=s2.split(".")[1].length}catch(e){}
return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m)
}
alert(Mul(14,19.9))
</script>
</body>
<script>
function Mul(n1,n2){
var m=0,s1=n1.toString(),s2=n2.toString();
try{m+=s1.split(".")[1].length}catch(e){}
try{m+=s2.split(".")[1].length}catch(e){}
return Number(s1.replace(".",""))*Number(s2.replace(".",""))/Math.pow(10,m)
}
alert(Mul(14,19.9))
</script>
</body>
String.prototype.fn = function(n)
{ s=""
for(i=0;i<n;i++)s+=this
return s
}
Number.prototype.fix = function(num)
{with(Math)return (round(this.valueOf()*pow(10,num))/pow(10,num)).toString().search(/\./i)==-1?(round(this.valueOf()*pow(10,num))/pow(10,num)).toString()+"."+"0".fn(num):(round(this.valueOf()*pow(10,num))/pow(10,num));
}
alert((14*19.9).fix(2));
</script>
上边的代码返回任意数的保留n位小数值,为了考虑货币的效果(xx.xx)形势,所以长了一点儿,因为4.00的格式是不能显示的(以数字方式),如果不用顾及那个用下边的就行
<script>
Number.prototype.fix = function(num)
{with(Math)return round(this.valueOf()*pow(10,num))/pow(10,num);
}
alert((14*19.9).fix(2));
</script>
Mul(<%=rs.getDouble(6)%>,<%=rs.getDouble(7)%>
Mul(<%=rs.getDouble(6)%>,<%=rs.getDouble(7)%>)