JavaScript Math.round()
Contoh
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);
Definisi dan Penggunaan
Metode Math.round() mengembalikan representasi float terdekat (presisi tunggal 32-bit) dari sebuah angka.
Dukungan Peramban
Math.fround()
adalah fitur ECMAScript6 (ES6).
ES6 (JavaScript 2015) didukung di semua browser modern:
Chrome | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes |
Math.fround()
tidak didukung di Internet Explorer 11 (atau lebih lama).
Sintaksis
Math.fround(x)
Parameter
Parameter | Description |
---|---|
x | Required. A number |
Nilai Kembali
Representasi float presisi tunggal 32-bit terdekat dari nomor thr. |