Talk:Hamming weight

Hamming weight of a CRC polynomial
This paper, koopman04_crc_poly_embedded.pdf by Koopman and Chakravarty is using Hamming weight to mean something completely different than popcount. And they use Hamming weight as a quality measurement on CRC polynomials. On page 2 in the paper they write: "A Hamming weight N is the number of errors, out of all possible message corruptions, that is undetected by a CRC using a particular polynomial. A set of Hamming weights captures performance for different numbers of bits corrupted in a message at a particular data word length, with each successively longer data word length having set of Hamming weights with higher values. The first non-zero Hamming weight determines a code’s Hamming Distance."

Jorgen.karlsson (talk) 21:11, 26 November 2016 (UTC)

---
Horrible!!

Please, symplify! it is for readers, not only for "copy/paste" testing programmers.

I disagree. The definition and background are clear and concise. Additional background is provided in the links and references. The advanced information is well-presented for anyone with a good grasp of arithmetic. The software examples are immediately useful to the people most likely to have a serious interest in this topic. 64.175.33.56 15:46, 15 November 2007 (UTC) Pictographer

Fast division
If you have fast division (or you want to calculate the population count of a constant at compile time) then you can replace the last few stages by taking the remainder of the division by 255 i.e.

int popcount_3(uint64 x) { x -= (x >> 1) & m1; x = (x & m2) + ((x >> 2) & m2); x = (x + (x >> 4)) & m4; return x % 255; }

or, an alternative version as a single-line C-style #define


 * 1) define popcount_4(x) (((x) & h01) + (((x) >> 1) & h01) + (((x) >> 2) & h01) + (((x) >> 3) & h01) + (((x) >> 4) & h01) + (((x) >> 5) & h01) + (((x) >> 6) & h01) % 127) —Preceding unsigned comment added by 80.175.250.218 (talk) 17:15, 13 March 2009 (UTC)

Should someone make note that in the example given, "Hello World" is counting the space character (ASCII 32) and not the null character (ASCII 0) as having 0 Hamming weight? 131.122.52.166 (talk) 06:37, 22 March 2011 (UTC)

Isolating one bit
As Wegner (1960) described,[3] the lowest-order nonzero bit of a word x may be found as the exclusive or of x with x − 1:

I don't have access to the reference, but the quote would seem to be inaccurate. As a four-bit example, (0100) ^ (0011) = (0111), which does not seem to isolate one bit. x & -x would seem to be a better method.

--50.47.202.254 (talk) 17:07, 23 June 2011 (UTC)
 * What Wegner actually says is that (rewritten symbolically) x&(x-1) eliminates the low order bit from x. He doesn't mention exclusive ors. —David Eppstein (talk) 19:04, 23 June 2011 (UTC)

Is lookup method faster?
It's said: If we are allowed greater memory usage, we can calculate the Hamming weight faster than the above methods, but unfortunately it's not true. The real-world benchmarks show that lookup table is slower than alternative approaches (even these described in the article), due to current CPU's architecture. The cited sentence should rather use word "simpler" instead of "faster". 195.66.98.6 (talk) 08:25, 22 March 2016 (UTC)

External links modified
Hello fellow Wikipedians,

I have just modified one external link on Hamming weight. Please take a moment to review my edit. If you have any questions, or need the bot to ignore the links, or the page altogether, please visit this simple FaQ for additional information. I made the following changes:
 * Added archive https://web.archive.org/web/20120118213535/http://www.sparc.org/standards/SPARCV9.pdf to http://www.sparc.org/standards/SPARCV9.pdf

When you have finished reviewing my changes, you may follow the instructions on the template below to fix any issues with the URLs.

Cheers.— InternetArchiveBot  (Report bug) 18:22, 28 October 2017 (UTC)

Merge from Minimum weight
I don't think we need a separate article with two sentences about the minimum value of the Hamming weight... --Piotr Konieczny aka Prokonsul Piotrus&#124; reply here 03:28, 1 July 2020 (UTC)


 * Merge: I agree, Wikipedia is not a dictionary, this definition belongs in the more comprehensive article.--Bill Cherowitzo (talk) 17:31, 1 July 2020 (UTC)
 * Merge content but do not redirect. "Minimum weight" is at best ambiguous; there are many other topics within mathematics that it could belong to such as minimum-weight triangulation, minimum weight spanning tree, etc., not to mention unrelated topics like weight class. I do not think that Hamming weight is likely to be the primary topic for that term. If it is required to leave a redirect for licensing purposes, then move to minimum Hamming weight (without leaving a redirect) prior to merging. —David Eppstein (talk) 17:57, 1 July 2020 (UTC)
 * Will switch that page to a dab now that ✅ Klbrain (talk) 14:59, 20 February 2021 (UTC)