From: "Allan, Bruce W" <bruce.w.allan@intel.com>
To: "linux-c-programming@vger.kernel.org"
<linux-c-programming@vger.kernel.org>,
"kernel-janitors@vger.kernel.org"
<kernel-janitors@vger.kernel.org>
Subject: boolean result from a test for a bit
Date: Fri, 27 Jan 2012 20:29:13 +0000 [thread overview]
Message-ID: <804857E1F29AAC47BF68C404FC60A1842485E4@ORSMSX102.amr.corp.intel.com> (raw)
For a simple boolean test of whether, for example, bit 5 is set in the variable 'flags', which of the following methods is preferred over the other?
bool result = (flags & (1 << 5)) ? true : false;
or
bool result = !!(flags & (1 << 5));
I've seen examples of both in the Linux kernel.
Thanks,
Bruce.
next reply other threads:[~2012-01-27 20:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-27 20:29 Allan, Bruce W [this message]
2012-02-18 1:47 ` boolean result from a test for a bit Phil Sutter
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=804857E1F29AAC47BF68C404FC60A1842485E4@ORSMSX102.amr.corp.intel.com \
--to=bruce.w.allan@intel.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-c-programming@vger.kernel.org \
/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 read-only IMAP folder(s) and NNTP newsgroup(s).