Skip to main content

Determining the Position of an Isolated Bit

The two obvious techniques for finding the bit position of an isolated bit are to shift repetitively with tests, as above, and to use floating normalization hardware. On the PDP-10, in particular, the JFFO instruction is made to order*. On machines with hexadecimal normalization, e.g. IBM 360's and XDS Sigma 7's, the normalization hardware may not be very convenient. A different approach uses division and table look-up.

                                                              k

A word with a single bit on has an unsigned integer value of 2 for

                                         k

0<=k<n. If we choose a p such that mod(2 ,p) is distinct for each 0<=k<n, we can make a table of length p which gives the correspondence

             k

between mod(2 ,p) and k. The remainder of this paper is concerned with the selection of an appropriate divisor p for each word length n.

*Some of the CDC machines have a "population count" instruction which

                                               k

gives the number of bits in a word. Note the 2 -1 has exactly k bits on.