boolean result from a test for a bit
"Allan, Bruce W" <[email protected]> Fri, 27 Jan 2012 20:29:13 +0000
| Newsgroups | org.kernel.vger.linux-c-programming,org.kernel.vger.kernel-janitors |
|---|---|
| Message-ID | <804857E1F29AAC47BF68C404FC60A1842485E4@ORSMSX102.amr.corp.intel.com> |
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.