Mail Archives: djgpp/1999/08/22/16:20:47
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 -