blob: 8ffb03e7c5e2ab762e43797c4a3a36057b28b770 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
/* ffs -- Find the first bit set in the parameter
NAME
ffs -- Find the first bit set in the parameter
SYNOPSIS
int ffs (int valu)
DESCRIPTION
Find the first bit set in the parameter. Bits are numbered from
right to left, starting with bit 1.
*/
int
ffs (valu)
register int valu;
{
register int bit;
if (valu == 0)
return 0;
for (bit = 1; !(valu & 1); bit++)
valu >>= 1;
return bit;
}
|