Orbit · Explore

Programming · by Noah Miller · 2026-10-28

A faster algorithm for 64-bit signed floor division

benjoffe.com

Nice deep dive on computing floor division for signed 64-bit ints faster than the usual 'divide then fix up' approach. Most languages truncate toward zero, Python floors, and the fix-up branch costs more than you'd think in hot loops. Has anyone actually hit this as a bottleneck in real code?

20 sparks · 2 comments

Comments

Mariam Said · 5 likes

I love posts like this, someone spending a week to save 2 cycles. the internet is healing

Silver Sparrow · 1 likes

Hit it once in a time bucketing service, negative timestamps before 1970 broke everything. floor div fixed correctness, perf was a bonus