Re: boolean result from a test for a bit

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

 




Am 27.01.2012 21:29, schrieb Allan, Bruce W:
> 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.
> --

hi Bruce,
i think this is a matter of taste, but i would say
personaly i would go for option one since since !! can
easely be overlooked.

personaly i do not like bool.

re,
 wh
--
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