此方法返回以指数表示法表示number对象的字符串。
number.toExponential( [fractionDigits] )
fractionDigits - 一个整数,指定小数点后的位数。
以指数表示法表示数字对象的字符串,小数点前有一位数,小数点后舍入为fractionDigits位数。
链接:https://www.learnfk.comhttps://www.learnfk.com/javascript/number-toexponential.html
来源:LearnFk无涯教程网
<html> <head> <title>Javascript Method toExponential()</title> </head> <body> <script type="text/javascript"> var num=77.1234; var val=num.toExponential(); document.write("num.toExponential() is : " + val ); document.write("<br />"); val=num.toExponential(4); document.write("num.toExponential(4) is : " + val ); document.write("<br />"); val=num.toExponential(2); document.write("num.toExponential(2) is : " + val); document.write("<br />"); val=77.1234.toExponential(); document.write("77.1234.toExponential()is : " + val ); document.write("<br />"); val=77.1234.toExponential(); document.write("77 .toExponential() is : " + val); </script> </body> </html>
运行上面代码输出
num.toExponential() is : 7.71234e+1 num.toExponential(4) is : 7.7123e+1 num.toExponential(2) is : 7.71e+1 77.1234.toExponential()is:7.71234e+1 77 .toExponential() is : 7.71234e+1
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)