JavaScript Math.fround()
示例
let a = Math.fround(2.60);
let b = Math.fround(2.50);
let c = Math.fround(2.49);
let d = Math.fround(-2.60);
let e = Math.fround(-2.50);
let f = Math.fround(-2.49);
自己動手試一試 »
描述
Math.fround()
方法返回最接近的 32 位單精度浮點數表示形式的數字。
JavaScript 四捨五入函式
Math.abs() 方法Math.ceil() 方法
Math.floor() 方法
Math.round() 方法
Math.fround() 方法
Math.trunc() 方法
語法
Math.fround(x)
引數
引數 | 描述 |
x | 必需。 一個數字。 |
返回值
型別 | 描述 |
Number | 數字的最接近的 32 位單精度浮點數表示形式。 |
瀏覽器支援
Math.fround()
是 ECMAScript6 (ES6) 功能。
自 2017 年 6 月起,所有現代瀏覽器都支援 ES6 (JavaScript 2015)
Chrome 51 | Edge 15 | Firefox 54 | Safari 10 | Opera 38 |
2016 年 5 月 | 2017 年 4 月 | 2017 年 6 月 | 2016 年 9 月 | 2016 年 6 月 |
Internet Explorer 不支援Math.fround()
。