All of lore.kernel.org
 help / color / mirror / Atom feed
* boolean result from a test for a bit
@ 2012-01-27 20:29 ` Allan, Bruce W
  0 siblings, 0 replies; 5+ messages in thread
From: Allan, Bruce W @ 2012-01-27 20:29 UTC (permalink / raw)
  To: kernel-janitors

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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-02-18  1:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-27 20:29 boolean result from a test for a bit Allan, Bruce W
2012-01-27 20:29 ` Allan, Bruce W
2012-01-28 10:31 ` walter harms
2012-02-18  1:47 ` Phil Sutter
2012-02-18  1:47   ` Phil Sutter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.