Mike Jacobs
asked on
BITCOUNT ALGORITHM? (to count the ones and zeroes in arbitrary stings)
Anyone know of a relatively straightforward algorithm for computing the numbers of ones and zeroes in an arbitrary string such that, we could address the function thus
Number_of_Ones=bitcount(ar bitrary_st ring,1)
Number_of_Zeroes=bitcount( arbitrary_ string,0)
Number_of_Ones=bitcount(ar
Number_of_Zeroes=bitcount(
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@phophric
nope. Don't care about the individual characters. Just need to know the number of 1s and 0s
@ Dr Klahn
that looks like it will do the trick. Thanks.
nope. Don't care about the individual characters. Just need to know the number of 1s and 0s
@ Dr Klahn
that looks like it will do the trick. Thanks.
ASKER
my main programming language is VFP but this query is not language specific. I may want to invoke it in Javascript, php, python or whatever. It's actually related to a test for whether or not a given bitstream has been transmitted using the "Chaffing and Winnowing" protocol described Ron Rivest, with a view to potential improvements to that protocol.
ASKER
haven't yet implemented it but this is clearly a solution to the problem.
Number_of_Ones=bitcount("A
Are you interested in analyzing the binary representation of these 3 chars, and then counting the number of bits that are 1.