数学。JavaScript 中的 fround() 函数


Math 对象的 fround() 函数接受一个浮点数并返回最近的 32 位单精度浮点数表示形式的一个数。如果给定的数字本身是整数,此函数将返回相同的值。

语法

语法如下:

Math.fround(160.98)

示例

 实时演示

<html>
<head>
   <title>JavaScript Example</title>
</head>
<body>
   <script type="text/javascript">
      var result = Math.fround(160.98);
      document.write("Fround value: "+result);
   </script>
</body>
</html>

输出

Fround value: 160.97999572753906

更新于: 2020 年 6 月 25 日

204 次浏览

开启你的职业生涯

完成课程,获得认证

开始吧
广告
© . All rights reserved.