A word selecting specified binary positions under a bitwise operation. To extract a stored bit at position , logically shift by and combine with the mask 1. Grouping thirty-two cells into one Java integer permits a compact representation of a Conway Game of Life board.
// Destination: computer-science.bigb
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.
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.
A bitboard represents occupied positions on a finite board by the bits of an integer. Bitwise operations combine occupancy masks and test whether pieces overlap.
Bitwise OR combines binary representations position by position: an output bit is one exactly when at least one input bit is one. On bit masks representing sets, it computes their union.

Articles by others on the same topic (0)

There are currently no matching articles.