Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1382790 > unrolled thread
| Started by | "George Spelvin" <linux@horizon.com> |
|---|---|
| First post | 2016-04-19 20:50 +0200 |
| Last post | 2016-04-25 18:20 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH V3 01/29] bitops: add parity functions "George Spelvin" <linux@horizon.com> - 2016-04-19 20:50 +0200
Re: [PATCH V3 01/29] bitops: add parity functions Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com> - 2016-04-25 11:20 +0200
Re: [PATCH V3 01/29] bitops: add parity functions "George Spelvin" <linux@horizon.com> - 2016-04-25 18:20 +0200
| From | "George Spelvin" <linux@horizon.com> |
|---|---|
| Date | 2016-04-19 20:50 +0200 |
| Subject | Re: [PATCH V3 01/29] bitops: add parity functions |
| Message-ID | <rpISK-2Sj-17@gated-at.bofh.it> |
> Add generic odd parity functions, adapted from > "https://graphics.stanford.edu/~seander/bithacks.html#ParityParallel" Given a PARITY_MAGIC of 0x6996, this is even parity, not odd. (Which it should be; an XOR of all bits is the "natural" form.)
[toc] | [next] | [standalone]
| From | Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com> |
|---|---|
| Date | 2016-04-25 11:20 +0200 |
| Message-ID | <rrKQq-3ck-29@gated-at.bofh.it> |
| In reply to | #1382790 |
在 2016年04月20日 02:45, George Spelvin 写道: >> Add generic odd parity functions, adapted from >> "https://graphics.stanford.edu/~seander/bithacks.html#ParityParallel" > Given a PARITY_MAGIC of 0x6996, this is even parity, not odd. > > (Which it should be; an XOR of all bits is the "natural" form.) From "http://www.encyclopedia.com/doc/1O11-oddparity.html", we can get the definition of "odd parity": odd parity A property that holds when a group of binary values contains an odd number of 1s.
[toc] | [prev] | [next] | [standalone]
| From | "George Spelvin" <linux@horizon.com> |
|---|---|
| Date | 2016-04-25 18:20 +0200 |
| Message-ID | <rrRoU-mn-33@gated-at.bofh.it> |
| In reply to | #1386160 |
>> Given a PARITY_MAGIC of 0x6996, this is even parity, not odd. > From "http://www.encyclopedia.com/doc/1O11-oddparity.html", we can get > the definition of "odd parity": > odd parity A property that holds when a group of binary values contains > an odd number of 1s. That's correct, but the group of bits being discussed *includes the parity bit itself*. Let me be specific: Let x be a word, which is BITS bits long. Let parity(x) = popcount(x) & 1 Let y = x | parity(x) << BITS Let z = x | !parity(x) << BITS y is described as having even parity. z is described as having odd parity. x is not normally described using those terms The bits appended are usually referred to as an "even parity bit" and an "odd parity bit". You're right that your function returns "true" if the word fed to it has odd parity, but the bit it computes is an even parity bit. In the field of error-checking codes, an inverse convention is generally used: zero means no error and non-zero means error. When this convention is used, the same function can be used to both generate and check parity. (And the one you have is the even parity function.) I think the best solution is to just delete the word "odd".
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web