From: Ian Farquhar <ifarqhar@laurel.ocs.mq.edu.au>
To: cypherpunks@toad.com
Message Hash: 1d7314d1fe69719702cb22aa2ae19b81662c71b4783d84df622e8a4c64309ac8
Message ID: <199407070257.AA00900@laurel.ocs.mq.edu.au>
Reply To: N/A
UTC Datetime: 1994-07-07 02:58:27 UTC
Raw Date: Wed, 6 Jul 94 19:58:27 PDT
From: Ian Farquhar <ifarqhar@laurel.ocs.mq.edu.au>
Date: Wed, 6 Jul 94 19:58:27 PDT
To: cypherpunks@toad.com
Subject: Bit counting
Message-ID: <199407070257.AA00900@laurel.ocs.mq.edu.au>
MIME-Version: 1.0
Content-Type: text/plain
>Why bother when you can simply do an eight line function?
>int bitcount(char b)
>{
>register int retval=0;
> if (a & 1) retval++;
> if (a & 2) retval++;
> if (a & 4) retval++;
> if (a & 8) retval++;
> if (a & 16) retval++;
> if (a & 32) retval++;
> if (a & 64) retval++;
> if (a & 128) retval++;
>return retval;
>}
[...]
Because on a lot of architectures this implementation may be hideously
inefficient. All the world is not an Intel chip, thank god.
Ian.
Return to July 1994
Return to “tim werner <werner@mc.ab.com>”