JavaScript fround() methode

Definitie en gebruik

fround() De methode retourneert de dichtstbijzijnde (32-bits single-precision) float-representatie van het getal.

Voorbeeld

Rond verschillende getallen af naar de dichtstbijzijnde (32-bits single-precision) float-representatie:

var a = Math.fround(2.60);
var b = Math.fround(2.50);
var c = Math.fround(2.49);
var d = Math.fround(-2.60);
var e = Math.fround(-2.50);
var f = Math.fround(-2.49);

Probeer het zelf

Syntaxis

Math.fround(x)

Parameterwaarde

Parameter Beschrijving
x Verplicht. Getal.

Technische details

Retourwaarde: Geef de dichtstbijzijnde 32-bits single-precision float-representatie van het getal terug.
JavaScript versie: ECMAScript 2015

Browser support

Method Chrome Edge Firefox Safari Opera
fround() 38.0 26.0 12.0 8.0 25.0

Related pages

Tutorial:JavaScript mathematics