cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/22/16:20:47

Date: Sat, 21 Aug 1999 09:43:53 +0700
From: Batchex <thedark1 AT Phreaker DOT net>
X-Mailer: The Bat! (v1.32) S/N E34104EF
X-Priority: 3 (Normal)
Message-ID: <2405.990821@Phreaker.net>
To: Davin McCall <djgpp AT delorie DOT com>
Subject: Re[4]: Bit counting?
In-reply-To: <37b9010b.24972024@newsserver.cc.monash.edu.au>
References: <37b9010b DOT 24972024 AT newsserver DOT cc DOT monash DOT edu DOT au>
Mime-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

Hi,

Tuesday, August 17, 1999, 1:33:31 PM, you wrote:

DM> You are using "value" each time. You should only use it the first
DM> time, and use "tempvalue" after that. To use your example (value = 7d
DM> = 111b, 3 bits are set):

>>2 bit sequemce:
>>value = 7
>>mask1 = 0000000000000111 & 0101010101010101 = 5
>>mask2 = 0000000000000111 & 1010101010101010 = 2
>>mask2 >>=1 = 1
>>tempvalue = mask1 + mask2 = 5 + 1 = 6


>>4 bit sequence:
>>value = 7
---->> rather, tempvalue = 6
>>mask1 = 0000000000000111 & 0011001100110011 = 3
>>mask2 = 0000000000000111 & 1100110011001100 = 4
--->> mask1 = 00000000000110 & 0011001100110011 = 2
DM>      mask2 = 00000000000110 & 1100110011001100 = 4
>>mask2 >>= 2 = 1
>>tempvalue = mask1 + mask2 = 3 + 1 = 4
DM>    .. = 2 + 1 = 3.

DM> Continuing the process will not change the value; "3" is the final
DM> answer.

DM> Hope this made things clear,

DM> Davin.

DM> __________________________________________________________
DM>        *** davmac - sharkin'!! davmac AT iname DOT com ***
DM> my programming page: http://yoyo.cc.monash.edu.au/~davmac/


I've tried this approach, but it will only gives the correct bit count
if value is as high as 15. Higher than 15 (16 and higher) will give
incorrect bit count. I've tried 8 bit values and go as far as 16 bit
sequences.

Batchex
mailto:thedark1 AT Phreaker DOT net


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019