Expand Right Bitwise Algorithm
问题 Originally this post requested an inverse sheep-and-goats operation, but I realized that it was more than I really needed, so I edited the title, because I only need an expand-right algorithm, which is simpler. The example that I described below is still relevant. Original Post: I'm trying to figure out how to do either an inverse sheep-and-goats operation or, even better, an expand-right-flip. According to Hacker's Delight, a sheeps-and-goats operation can be represented by: SAG(x, m) =