<script language=JavaScript>
function tofloat(f,dec) {
if(dec<0) return "Error:dec<0!";
result=parseInt(f)+(dec==0?"":".");
f-=parseInt(f);
if(f==0)
for(i=0;i<dec;i++) result+='0';
else {
for(i=0;i<dec;i++) f*=10;
result+=parseInt(Math.round(f));
}
return result;
}
alert(tofloat(11.20000000000000000001,2))
</script>
function tofloat(f,dec) {
if(dec<0) return "Error:dec<0!";
result=parseInt(f)+(dec==0?"":".");
f-=parseInt(f);
if(f==0)
for(i=0;i<dec;i++) result+='0';
else {
for(i=0;i<dec;i++) f*=10;
result+=parseInt(Math.round(f));
}
return result;
}
alert(tofloat(11.20000000000000000001,2))
</script>
alert(2.333333.toFixed(2))
var tmp = 200.42521
var tmp1 = tmp * Math.pow(10,2)
var tmp2 = Math.round(tmp1) / Math.pow(10,2)
alert(tmp2)
</script>