數學。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.