189857Sobrien/* ffs -- Find the first bit set in the parameter
289857Sobrien
389857Sobrien@deftypefn Supplemental int ffs (int @var{valu})
489857Sobrien
589857SobrienFind the first (least significant) bit set in @var{valu}.  Bits are
689857Sobriennumbered from right to left, starting with bit 1 (corresponding to the
789857Sobrienvalue 1).  If @var{valu} is zero, zero is returned.
889857Sobrien
989857Sobrien@end deftypefn
1089857Sobrien
1189857Sobrien*/
1289857Sobrien
1389857Sobrienint
14218822Sdimffs (register int valu)
1589857Sobrien{
1689857Sobrien  register int bit;
1789857Sobrien
1889857Sobrien  if (valu == 0)
1989857Sobrien    return 0;
2089857Sobrien
2189857Sobrien  for (bit = 1; !(valu & 1); bit++)
2289857Sobrien  	valu >>= 1;
2389857Sobrien
2489857Sobrien  return bit;
2589857Sobrien}
2689857Sobrien
27