Valentina wrote:
What does this C++ line mean?
bool bBoolean = (0!=(nInteger&0x08));
// I like to separate operands and operators
bool bBoolean = (0 != (nInteger & 0x08));
I don't understand the nInteger&0x08 bit.
'&' is the bitwise AND operator
// 00010111 = 23 in binary | 00011000 = 24 in binary
// & 00001000 = 8 in binary | & 00001000 = 8 in binary
// ---------- | ----------
// 00000000 = 23 & 8 ( == 0 ) | 00001000 = 24 & 8 ( != 0 )
that line is testing nInteger's fourth bit from the left;
if it's 0 bBoolean will be false, if it's 1 bBoolean will be true.
HTH
--
USENET would be a better place if everybody read: | to email me: use |
http://www.catb.org/~esr/faqs/smart-questions.html | my name in "To:" |
http://www.netmeister.org/news/learn2quote2.html | header, textonly |
http://www.expita.com/nomime.html | no attachments. |