JavaScript Math.fround()
Esempio
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);
Definizione e utilizzo
Il metodo Math.fround() restituisce la rappresentazione float più vicina (precisione singola a 32 bit) di un numero.
Supporto browser
Math.fround()
è una funzione ECMAScript6 (ES6).
ES6 (JavaScript 2015) è supportato in tutti i browser moderni:
Chrome | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes |
Math.fround()
non è supportato in Internet Explorer 11 (o versioni precedenti).
Sintassi
Math.fround(x)
Parametri
Parameter | Description |
---|---|
x | Required. A number |
Valore di ritorno
La rappresentazione float a precisione singola a 32 bit più vicina del numero. |