HeadlinesBriefing favicon HeadlinesBriefing.com

libbeef: Rust Port of Bellard's libbf Brings Full IEEE 754 Arithmetic

Hacker News •
×

Developer lifthrasiir released libbeef, a pure Rust implementation of Fabrice Bellard's libbf arbitrary-precision floating-point library. The port delivers complete IEEE 754 semantics including signed zeros, NaN, infinities, subnormals, and all five rounding modes. It supports transcendental functions like exp, log, sin, cos, tan, and both binary and decimal floating-point formats.

Performance benchmarks show libbeef maintains the same algorithmic complexity as the C original, using NTT-based multiplication and AGM/binary-splitting for transcendentals. At 300k bits, it achieves roughly 2x the speed of libbf while staying within 1.3x of GMP performance. The library is no_std compatible requiring only alloc, making it suitable for embedded systems and WASM targets.

The key advantages are its zero-dependency pure Rust implementation and small binary footprint—just 482KB stripped compared to rug's 680KB with GMP/MPFR statically linked. It passes the full verification suite across all operations and rounding modes, ensuring correct IEEE 754 compliance.

However, GMP/MPFR via rug remains superior for maximum throughput at precisions above 10k bits due to heavily tuned FFT implementations. Integer-only workloads should use num-bigint or malachite instead. libbeef shines for projects needing portable, permissively-licensed floating-point arithmetic without system dependencies.

libbeef fills a gap for developers who need arbitrary-precision floating-point math in Rust without wrestling with C library dependencies or LGPL licensing concerns.