From: "George Spelvin" <linux@horizon.com>
To: linux-kernel@vger.kernel.org, linux@horizon.com,
zengzhaoxiu@163.com, zhaoxiu.zeng@gmail.com
Cc: akpm@linux-foundation.org, arnd@arndb.de, dvlasenk@redhat.com,
linux-arch@vger.kernel.org, martink@posteo.de, mingo@kernel.org,
sasha.levin@oracle.com, yury.norov@gmail.com
Subject: Re: [PATCH V3 01/29] bitops: add parity functions
Date: 25 Apr 2016 12:17:09 -0400 [thread overview]
Message-ID: <20160425161709.15792.qmail@ns.horizon.com> (raw)
In-Reply-To: <571DDFE3.9010407@gmail.com>
>> 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".
prev parent reply other threads:[~2016-04-25 16:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-14 2:41 [PATCH V3 01/29] bitops: add parity functions zengzhaoxiu
2016-04-14 2:41 ` zengzhaoxiu
2016-04-19 18:45 ` George Spelvin
2016-04-19 18:45 ` George Spelvin
2016-04-25 9:14 ` Zeng Zhaoxiu
2016-04-25 16:17 ` George Spelvin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160425161709.15792.qmail@ns.horizon.com \
--to=linux@horizon.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=dvlasenk@redhat.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martink@posteo.de \
--cc=mingo@kernel.org \
--cc=sasha.levin@oracle.com \
--cc=yury.norov@gmail.com \
--cc=zengzhaoxiu@163.com \
--cc=zhaoxiu.zeng@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).