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: }
Defined functions
bitpos
defined in line
9; used 5 times