1: /*
   2: **  FIND HIGH ORDER BIT POSITION
   3: **
   4: **	The position of the highest ordered one bit in `word' is
   5: **	found and returned.  Bits are numbered 0 -> 15, from
   6: **	right (low-order) to left (high-order) in word.
   7: */
   8: 
   9: bitpos(word)
  10: int word;
  11: {
  12:     register int    wd, i, j;
  13:     int     pos;
  14: 
  15:     wd = word;
  16: 
  17:     pos = -1;
  18: 
  19:     for (i = 1, j = 0; wd; i <<= 1, j++)
  20:     {
  21:         if (wd & i)
  22:         {
  23:             pos = j;
  24:             wd &= ~i;
  25:         }
  26:     }
  27: 
  28:     return (pos);
  29: }
Last modified: 1995-02-04
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1652
Valid CSS Valid XHTML 1.0 Strict