在javascript中,0.6*3,结果为什么是1.799999999998,怎么才能变成应得的1.8;如何将3*3的结果格式化为9.0,而不是9?谢谢!
wtoeb 2003-08-24 04:45:15 在javascript中,0.6*3,结果为什么是1.799999999998,怎么才能变成应得的1.8;如何将3*3的结果格式化为9.0,而不是9?谢谢!
<script>
<!--
function test(){
result=parseFloat(document.pns.n1.value)*parseFloat(document.pns.n2.value);
alert(result);
}
-->
</script>
<form name=pns action=# method=post>
<input name=n1 value=3>
<input name=n2 value=0.6>
<input type=button value=yes onclick="test()">
</form>