JS Built-ins
← Math123 / 215
Mathfroundbeginner

Math.fround() β€” One

πŸ“– Usage Example
// Nearest 32-bit single-precision float
Math.fround(1.337)   // β†’ 1.3370000124...
Math.fround(1.5)     // β†’ 1.5

Use Math.fround() to convert a number to the nearest 32-bit float, useful when working with WebGL or typed arrays.

Math.fround()

Returns the nearest 32-bit single precision float representation of a number.

Challenge: Verify that Math.fround(1) equals 1 exactly.

πŸ’‘ Hints (1)
  • β€’ Integers that fit in 32-bit float are represented exactly