JS Built-ins
← Math121 / 215
Mathfroundadvanced

Math.fround() β€” Precision Loss

πŸ“– 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: Observe how Math.fround(1.337) differs from the original 64-bit float value.

πŸ’‘ Hints (1)
  • β€’ Math.fround converts to 32-bit float, losing precision compared to 64-bit