Submission timeline
2007–2026One slot for every year since HN launched. Height is that year's peak points; orange marks a 100+ point or 50+ comment breakout. Select a bar to open its strongest thread.
First comments on top threads
HN comment orderThis kind of hacks is a major part of how we made Scala.js' 64-bit integers fast (the fastest known implementation of 64-bit integers on JavaScript). See [1] for the implementation, and [2] at section 4.4 for the long explanation with benchmarks and the other tricks we use. [1] https://github.com/scala-js/scala-js/blob/v1.3.1/linker-priv... [2] https://lampwww.epfl.ch/~doeraene/thesis/doeraene-thesis-201...
My favourite bit of bit twiddling doesn't seem to appear here - how to enumerate all the subsets of bits set. Like so many bit-twiddling hacks, I first saw this in chess engines: https://www.chessprogramming.org/Traversing_Subsets_of_a_Set
Just a fair warning as someone who has made extensive use of this page in the past: many of these hacks often end up slower these days on modern CPUs than naive approaches. Especially the no-branch and no-multiply math ops. As always, be sure to performance test your code if you're getting into obfuscating your algorithms to boost speeds. That said, there are still plenty of real gems in there. And on that note, here's one of my favorite bit-twiddling…
It's worth noting that modern x86 CPUs have specialized extensions for bit manipulation. Furthermore C23 added stdbit.h that has some operations for bit manipulation https://en.wikipedia.org/wiki/X86_Bit_manipulation_instructi... https://thephd.dev/_vendor/future_cxx/papers/C%20-%20Modern%...
The first top-level comment from each of the four biggest threads, in HN’s own order. Excerpts are shortened; open a comment for full context.
- Breakout years
- 3
- Total points
- 922
- Total comments
- 167
100+ points or 50+ comments
reference only — not used in Hall rules or ranking
reference only — not used in Hall rules or ranking
Every submission
| Date | Title as submitted | By | Points | Comments |
|---|---|---|---|---|
| 2007-12-05 | Bit Twiddling Hacks | hhm | 18 | 3 |
| 2009-03-12 | Bit Twiddling Hacks | mroman | 49 | 6 |
| 2010-07-16 | Bit Twiddling Hacks | dsc | 3 | 0 |
| 2011-03-20 | Bit Twiddling Hacks | nathanh | 2 | 2 |
| 2011-05-21 | Bit Twiddling Hacks | wglb | 60 | 14 |
| 2011-06-07 | Bit Twiddling Hacks | coliveira | 29 | 4 |
| 2012-01-11 | Bit Twiddling Hacks | ahalan | 50 | 17 |
| 2012-02-12 | Fastest way to count set bits. | snihalani | 2 | 0 |
| 2012-05-28 | Bit Twiddling Hacks | pagejim | 3 | 0 |
| 2012-10-05 | My goto source for bit hacks. | sinzone | 4 | 0 |
| 2012-12-26 | Bit Twiddling Hacks | naftaliharris | 5 | 0 |
| 2013-02-20 | Bit Twiddling Hacks | pagejim | 2 | 0 |
| 2013-12-19 | Bit Twiddling Hacks | bratfarrar | 6 | 0 |
| 2014-12-15 | Bit Twiddling Hacks (2005) | thealphanerd | 50 | 6 |
| 2015-01-30 | Bit Twiddling Hacks | aburan28 | 2 | 0 |
| 2015-02-15 | Bit Twiddling Hacks | allending | 2 | 0 |
| 2015-05-04 | Counting bits set: Brian Kernighan's way | ruuki | 2 | 0 |
| 2015-05-13 | Bit twiddling hacks for programmers | tjomk | 3 | 0 |
| 2015-06-23 | Bit Twiddling Hacks | joemanaco | 2 | 0 |
| 2015-08-22 | Bit Twiddling Hacks – Sean Eron Anderson | s_dev | 2 | 0 |
| 2016-03-21 | Bit twiddling hacks (2005) | lgessler | 2 | 1 |
| 2016-07-03 | Bit Twiddling Hacks (2005)First breakout | e-sushi | 127 | 24 |
| 2017-10-06 | Bit Twiddling Hacks | relyio | 1 | 0 |
| 2017-10-07 | Bit Twiddling Hacks | geospeck | 1 | 0 |
| 2017-10-09 | Bithacks | dlsym | 7 | 1 |
| 2017-11-07 | Bit Twiddling Hacks | pantuza | 3 | 0 |
| 2017-11-19 | Bit Twiddling Hacks (2005) | kercker | 66 | 3 |
| 2018-03-27 | Bit Twiddling Hacks | raviqqe42 | 1 | 0 |
| 2018-07-27 | Bit Twiddling Hacks | DarkManZero | 1 | 0 |
| 2019-05-01 | Bit Twiddling Hacks | jakobdabo | 4 | 0 |
| 2019-10-24 | Bit Twiddling Hacks | ingve | 3 | 0 |
| 2020-01-17 | Bit Twiddling Hacks | slowhand09 | 2 | 0 |
| 2020-03-31 | Bit Twiddling Hacks | simonpure | 2 | 0 |
| 2020-12-04 | Bit Twiddling HacksBest thread | Cieplak | 143 | 33 |
| 2022-03-16 | Bithacks | galkk | 1 | 0 |
| 2022-04-23 | Bit Twiddling Hacks | gballan | 4 | 0 |
| 2022-10-11 | Bit Twiddling Hacks (2005) | cardamomo | 2 | 0 |
| 2022-10-23 | Bit Twiddling Hacks (2005) | pabs3 | 2 | 0 |
| 2022-10-25 | Bit Twiddling Hacks (2005) | memorable | 136 | 25 |
| 2024-02-22 | Bit Twiddling Hacks | prvt | 3 | 0 |
| 2024-04-20 | Bit Twiddling Hacks | yudga | 3 | 1 |
| 2024-04-20 | Bit Twiddling Hacks | makapuf | 14 | 1 |
| 2024-05-29 | Bit Twiddling Hacks | jihadjihad | 1 | 0 |
| 2024-08-23 | Bit Twiddling Hacks (2009)Latest 20+ point return | elpocko | 92 | 25 |
| 2025-12-11 | Bit Twiddling Hacks | gurjeet | 2 | 1 |
| 2026-05-26 | Bit Twiddling Hacks | tosh | 3 | 0 |
