boolean result from a test for a bit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux