Article

A faster way to compute signed 64-bit floor division by constants

benjoffe ·Lobsters ·Published 2026-10-26

What is signed integer floor division? Signed integer floor division is where you do a/b and get a result that rounds towards − ∞ , whereas standard ( “truncated” ) signed division rounds towards 0 . As stated in Hacker's Delight: “[I…

From the article

What is signed integer floor division? Signed integer floor division is where you do a/b and get a result that rounds towards − ∞ , whereas standard ( “truncated” ) signed division rounds towards 0 . As stated in Hacker's Delight: “[I suspect that] floor division more often gives the result you want” . This article is about floor division where the divisor is known at compile time .

Despite the usefulness of this function, the world of integer floor division is in shambles:

This blog post aims to not only shine light on the fast algorithms, but will also introduce a new fast approach which, with ideal compilation:


Share this resource


Discovered 2026-10-27 Source Lobsters Archive 2026-10 →