You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(bf16): rewrite f32ToBf16/bf16ToF32 as standard IEEE 754 bit ops (#53)
Previous implementation had multiple bugs:
- Exponent clamped to ±7 instead of IEEE-754 ±127 (7-bit range vs 8-bit)
- Wrong mantissa width (8 bits instead of 7)
- Wrong bit layout for decode (7-bit exp + 8-bit mantissa instead of 8+7)
- Wrong bias handling in frexp path
Standard BF16 is simply the top 16 bits of an IEEE 754 f32:
[S:1][E:8][M:7] = bits 31..16 of f32
This replaces 54 lines of broken frexp-based code with 2 lines of
correct bit manipulation, matching every major BF16 implementation
(PyTorch, TensorFlow, MLX, etc.).
Added 5 new BF16 tests covering: 1.0, 100.0, 1e10, small values,
and special values (inf, NaN, ±0).
Closes#22
0 commit comments