Math.fround

fround — Returns the nearest single-precision floating-point format of a number.

Description

Math.fround(number number)

Parameters

Name Description Type Default Optional
number number No

Examples

Example #1 – fround example
console.log(Math.fround(1)); // 1 console.log(Math.fround(1.0)); // 1 console.log(Math.fround(1.2)); // 1.2000000476837158 console.log(Math.fround(1.49)); // 1.4900000095367432 console.log(Math.fround(1.5)); // 1 console.log(Math.fround(1.8)); // 1.7999999523162842 console.log(Math.fround(2)); // 2

See also

External references