Example 1 — Basic Use
Some numbers are stored exactly. Others are rounded.
console.log(Math.f16round(5)); // 5
console.log(Math.f16round(5.5)); // 5.5
console.log(Math.f16round(5.05)); // 5.05078125
console.log(Math.f16round(0.1)); // 0.0999755859375 How It Works
- Exact values.
5and5.5fit exactly in 16 bits, so they do not change. - Rounded values.
5.05becomes5.05078125, the closest 16-bit float. - Fractions.
0.1cannot be stored exactly, so you see a small difference.

