Changeset 153 for sbliveos2/trunk/lib32/misc.c
- Timestamp:
- Jul 23, 2000, 6:21:57 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sbliveos2/trunk/lib32/misc.c
r151 r153 210 210 211 211 212 /* --------------------------------------------------------------------- */ 213 /* 214 * hweightN: returns the hamming weight (i.e. the number 215 * of bits set) of a N-bit word 216 */ 217 218 #ifdef hweight32 219 #undef hweight32 220 #endif 221 222 unsigned int hweight32(unsigned int w) 223 { 224 unsigned int res = (w & 0x55555555) + ((w >> 1) & 0x55555555); 225 res = (res & 0x33333333) + ((res >> 2) & 0x33333333); 226 res = (res & 0x0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F); 227 res = (res & 0x00FF00FF) + ((res >> 8) & 0x00FF00FF); 228 return (res & 0x0000FFFF) + ((res >> 16) & 0x0000FFFF); 229 }
Note:
See TracChangeset
for help on using the changeset viewer.