According to this quesiton: Java - Number of 1s = 0s in bit string, Bohemian (diamond moderator) commented to me while I am trying to help the asker with this comment"
"That is not relevant or desirable. I am seeking to clarify the question, to make it more valuable. Shotgun answers only encourage poorly defined questions"
Here, the user wants to count the number of ones and zeroes in a particular bit string using bitwise operators. However, he converted the initial int variable into a BigInteger
, and then into the String representation of this BigInteger
. It seems that this question is quite unclear (as how Bohemian stated that it is a "poorly defined question", since he didn't give an example of what a "bit string" is, and how he confuses "bit Strings" with numerical values such as a BigInteger
or a primitive int
. By the meaning of "bit string" I assumed that the bit string can be of any length, which may be far larger than even the largest value stored by a long
I have already provided the answer using the best of my efforts so hopefully the asker will understand how to count the bits of a numerical value (aka "bit string") using bitwise operators for both BigIntegers
and primitive integers and dismisses BigInteger
. However, the other answer deals with only integers, also it is upvoted.
I have edited and reposted my answer because based on Bohemian's comment, my answer could be a "shotgun answer" for a "poorly defined question," until I can edit it to become more relevant. However, from the user's comment, my answer isn't a "fastest gun in the west" answer, but I used my effort to help the asker the best I can, and give instructions how to reproduce it (it is easy to reproduce anyhow). The previous answer that got upvoted came first.
Is my answer a "shotgun question" to a "poorly defined question?"
2 * #1's == bit length
, then figure out how to determine bit length / count) which can be researched or asked about.