Hi Kostik, * Konstantin Belousov <[email protected]>, 20110709 16:29: > +static __inline uint16_t > +bitcount16(uint32_t x)
Shouldn't we use uint16_t for the argument here?
When I saw the code, I thought by myself, this could be done more
efficiently:
| static __inline uint16_t
| bitcount16(uint16_t x)
| {
|
| x = (x & 0x5555) + ((x >> 1) & 0x5555);
| x = (x & 0x3333) + ((x >> 2) & 0x3333);
| x *= 0x1111;
| return (x >> 12);
| }
But some testing revealed it works for all inputs, except 65536. d'oh!
--
Ed Schouten <[email protected]>
WWW: http://80386.nl/
pgpx7LrajIhTa.pgp
Description: PGP signature
