1994-07-07 - Re: Bit counting

Header Data

From: tim werner <werner@mc.ab.com>
To: ifarqhar@laurel.ocs.mq.edu.au
Message Hash: a896bbc7082ea6e9da7c54dd1148367f147fb4db79f047440f223179fe252a08
Message ID: <199407071152.HAA24431@sparcserver.mc.ab.com>
Reply To: <199407070257.AA00900@laurel.ocs.mq.edu.au>
UTC Datetime: 1994-07-07 11:53:19 UTC
Raw Date: Thu, 7 Jul 94 04:53:19 PDT

Raw message

From: tim werner <werner@mc.ab.com>
Date: Thu, 7 Jul 94 04:53:19 PDT
To: ifarqhar@laurel.ocs.mq.edu.au
Subject: Re: Bit counting
In-Reply-To: <199407070257.AA00900@laurel.ocs.mq.edu.au>
Message-ID: <199407071152.HAA24431@sparcserver.mc.ab.com>
MIME-Version: 1.0
Content-Type: text/plain


>From: Ian Farquhar <ifarqhar@laurel.ocs.mq.edu.au>
>Date: Thu, 7 Jul 1994 12:57:54 +1000 (EST)
>
>>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++;
        etc.
>>return retval;
>>}
>
>Because on a lot of architectures this implementation may be hideously
>inefficient.  All the world is not an Intel chip, thank god.

Not to mention it's only good for 8-bit words.  In my case I am working
with 16-bit data.

tw





Thread