Find First Set

In software, find first set (ffs) or find first one is a bit operation that, given an unsigned machine word, identifies the least significant index or position of the bits set to one in the word. A nearly equivalent operation is count trailing zeros (ctz) or number of trailing zeros (ntz), which counts the number of zero bits following the least significant one bit. The complementary operation that finds the index or position of the most significant set bit is log base 2, so called because it computes the binary logarithm . This is closely related to count leading zeros (clz) or number of leading zeros (nlz), which counts the number of zero bits preceding the most significant one bit. These four operations also have negated versions:

  • find first zero (ffz), which identifies the index of the least significant zero bit;
  • count trailing ones, which counts the number of one bits following the least significant zero bit.
  • count leading ones, which counts the number of one bits preceding the most significant zero bit;
  • The operation that finds the index of the most significant zero bit, which does not have a common name.

There are two common variants of find first set, the POSIX definition which starts indexing of bits at 1, herein labelled ffs, and the variant which starts indexing of bits at zero, which is equivalent to ctz and so will be called by that name.

Read more about Find First Set:  Examples, Hardware Support, Tool and Library Support, Properties and Relations, Algorithms, Applications

Famous quotes containing the words find and/or set:

    Push, labor, shove,—these words of great power in a city like this. Two years must find me with a living and increasing business, or I quit the city and probably the profession.
    Rutherford Birchard Hayes (1822–1893)

    We set up a certain aim, and put ourselves of our own will into the power of a certain current. Once having done that, we find ourselves committed to usages and customs which we had not before fully known, but from which we cannot depart without giving up the end which we have chosen. But we have no right, therefore, to claim that we are under the yoke of necessity. We might as well say that the man whom we see struggling vainly in the current of Niagara could not have helped jumping in.
    Anna C. Brackett (1836–1911)