flâneur

A faster way to calculate the day-of-the-week

benjoffe.com · 5,787 words · saved by 1 readers

A range of fast modulus techniques that beat compiler output

A range of fast modulus techniques that beat compiler output 17 August 2026 Converting a day-count ("rata-die") to the day-of-the-week (“weekday”) sounds like it should be so trivial, that there's almost nothing to say about it. But, as it turns out, when we look under the hood, this is a surprisingly complex problem. Throughout this article I will present a range of really fast functions to solve this problem, tuned for different use cases (throughput vs latency, different platforms etc.). Each (full range 32-bit algorithm) outperforms existing solutions, and many have a latency of just…

saved by

related reading