Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ ffs(3C) — DG/UX 4.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought



                                                                  ffs(3C)



        _________________________________________________________________
        ffs                                                      function
        Return the first bit in an integer that is one.
        _________________________________________________________________


        Calling Sequence

        int ffs(), bitnum, number;
        bitnum = ffs(number);




          where   number is the integer tested for the set bit.



        Description

        The ffs function returns the first bit set to 1 in an integer;
        this function comes from the University of California Berkeley
        UNIX (BSD) system.


        Returns

        The ffs function returns the first set bit, starting with the
        least significant bit.  For example, ffs(0) returns 0, ffs(1)
        returns 1, and ffs(16) returns 5.


        Related Functions

        See also the bitset function.


        Example

        The following program demonstrates the ffs function for each
        power of two from 0 - 15 and 0.

        /* Program test for the ffs() function */

        #include <stdio.h>


        int ffs(), i = 1;

        main() {
            printf("ffs(%#08x) = %d.\n", i, ffs(i));



        DG/UX 4.00                                                 Page 1
               Licensed material--property of copyright holder(s)





                                                                  ffs(3C)



            do {
                i <<= 1;
                printf("ffs(%#08x) = %d.\n", i, ffs(i));
            } while (i != 0);
            return 0;
        }
















































        DG/UX 4.00                                                 Page 2
               Licensed material--property of copyright holder(s)



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026