The Math.fround(number) function

The Math.fround() function rounds a number to a 32-bit floating point value. Here is an example to demonstrate this:

console.log(Math.fround(0));console.log(Math.fround(1));console.log(Math.fround(1.137));console.log(Math.fround(1.5));

The output is as follows:

011.13699996471405031.5

Get Learn ECMAScript - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.