JS Built-ins
← Math122 / 215
Mathfroundbeginner

Math.fround() β€” Zero

πŸ“– 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(0) equals 0.

πŸ’‘ Hints (1)
  • β€’ Zero is represented exactly in all floating-point formats