The article presents optimized algorithms for signed 64-bit floor division by compile-time constants, which round toward -∞ unlike standard truncating division. The author introduces a new approach that benchmarks 10-20% faster on ARM and 5-10% faster on x86 for most divisors, addressing gaps in mainstream compiler support and prior art in Hacker's Delight.
Background
Floor division is commonly needed in languages like Python but absent from C/C++/Go/Swift. Low-level math optimization literature, particularly Hacker's Delight, has notably lacked comprehensive coverage of fast signed floor division algorithms.
- Source
- Lobsters
- Published
- Oct 27, 2026 at 02:44 AM
- Score
- 7.0 / 10