The other day I was thinking about how you might do a binary search branchlessly. I came up with a way, and I’m pretty sure I’m not the first to come up with it, but it was fun to think about and I wanted to share my solution. All code in this post is public domain. Here it is searching a list of 8 items in 3 steps: size_t BinarySearch8 (size_t needle, const size_t haystack[8]) { size_t ret = (hay
