VBScript Round 函数

Round 函数对数字进行四舍五入。
语法
Round(expression[,numdecimalplaces])
参数 | 描述 |
---|---|
expression | 必需。需要被四舍五入的数值表达式。 |
numdecimalplaces | 可选。规定对小数点右边的多少位进行四舍五入。默认是 0。 |
实例
实例 1
<script type="text/vbscript">
document.write(Round(24.13278) & "<br />")
document.write(Round(24.75122))
</script>
document.write(Round(24.13278) & "<br />")
document.write(Round(24.75122))
</script>
以上实例输出结果:
24
25
25
尝试一下 »
实例 2
如何对一个数字进行四舍五入,保留 2 位小数:
<script type="text/vbscript">
document.write(Round(24.13278,2))
</script>
document.write(Round(24.13278,2))
</script>
以上实例输出结果:
24.13
尝试一下 »
