toFixed() 方法指定小数位个数
toExponential() 方法 用科学计数法表示数,参数指定小数位个数
toPrecision() 方法自动判断调用toFixed()或toExponential()方法,参数指定所有数的位数
实现代码如下:

var num = 99;
alert(toFixed(2)); //99.00
alert(toExponential(1)); //9.0e+1
alert(toPrecision(1)); //9.0e+1
alert(toPrecision(2)); //99
alert(toPrecision(3)); //99.0

以上就是【JavaScript学习日志(四) Number 数字类型】的全部内容了,欢迎留言评论进行交流!

赞(0) 踩(0)

与本文相关的软件

发表我的评论

最新评论

  1. 暂无评论