<html> <body> <script language="javascript"> var a = "0.11"; var b = "0.2801"; var c = "1.002"; var sum1 = parseFloat(a)+parseFloat(b)+parseFloat(c); var sum2 = (parseFloat(a)+parseFloat(b)+parseFloat(c)).toFixed(4) document.write("a+b+c="+sum1); document.write("<br/>") document.write("a+b+c="+sum2) document.write("<br/>") var num=new Number(sum2); document.write("sum2.toFixed(2)= "+num.toFixed(2)); </script> </body> </html>
时间: 2024-10-18 14:09:59