JavaScript fround() method

Definition and usage

fround() The method returns the closest (32-bit single-precision) floating-point representation of the number.

Example

Round different numbers to the nearest (32-bit single-precision) floating-point representation:

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);

Try it yourself

Syntax

Math.fround(x)

Parameter value

Parameter Description
x Required. Number.

Technical details

Return value: Return the nearest 32-bit single-precision floating-point representation of a number.
JavaScript version: ECMAScript 2015

Webbläsarstöd

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

Relaterade sidor

Lär dig om:JavaScript matematik