2 * UCW Library -- Find Highest Set Bit
4 * (c) 1997-2005 Martin Mares <mj@ucw.cz>
6 * This software may be freely distributed and used according to the terms
7 * of the GNU Lesser General Public License.
11 #include "ucw/bitops.h"
22 if (x & 0xffff0000) { l += 16; x &= 0xffff0000; }
23 if (x & 0xff00ff00) { l += 8; x &= 0xff00ff00; }
24 if (x & 0xf0f0f0f0) { l += 4; x &= 0xf0f0f0f0; }
25 if (x & 0xcccccccc) { l += 2; x &= 0xcccccccc; }
26 if (x & 0xaaaaaaaa) l++;
37 while (scanf("%x", &i) == 1)
38 printf("%d\n", bit_fls(i));