Submask 2026-11-05
A submask of a bit mask is a bit mask whose set bits are all set in , equivalently . It represents a subset of the positions selected by . If has set bits, it has exactly submasks, including zero.
To enumerate them in descending order, start at , output , stop if , and otherwise replace it by . Subtracting one clears the lowest set bit and fills lower positions; masking removes positions unavailable in . For , the sequence is . Testing for zero before the next update is essential: under the common integer conventions, updating zero produces again and repeats the cycle.[ref] The number of outputs is exponential in the number of selected positions, even though each fixed-word update is inexpensive.
Submask enumeration Created 2026-10-20 Updated 2026-11-05
A submask of a bit mask has no set bits outside . Start with and repeatedly replace a positive by
Process each positive before this update and stop when it becomes zero. To include the empty submask, process zero once and stop before updating it; otherwise the update can return to .
Subtracting one clears the lowest set bit and sets the lower positions. The bitwise AND with removes forbidden positions, producing the largest permitted submask strictly below the previous one. This proves decreasing order, no duplicates and no skipped submask.
For , the order is . A bit mask with set bits has submasks, because each allowed position is independently selected or omitted. Enumeration therefore takes updates under constant-cost bitwise operations; has only the empty submask.