Microsoft
Software
Hardware
Network
Question : Reading bits in C++
Hi,
Let's say I have a five byte data element "char m_TxBuf[5]" and I need to determine if a bit is set (high or not) in one of the elements, let's say for example in m_TxBuf[2] --> bit 3. (00001000) how do I determine this in C++.
Thanks for your support!
Answer : Reading bits in C++
First of all, it's best to use unsigned char when dealing with bits.
And to answer your question, this checks whether bit 3 is set in the third byte :
1: 2: 3: 4: 5:
unsigned char m_TxBuf[5]; if (m_TxBuf[2] & 0x08) { /* the bit is set */ }
Random Solutions
Oracle SQL: why this regular expression doesn't work?
Server 2008 will restart on its own with this error during DC promo to this server
isa 2004 - opening up port 1433 to one external IP address for SQL server
Popup menu onclick doesn't fire event
The user groups are only accessible by directly typing in the URL
Looking for bicycle cadence indicator using colored LEDs to show speed
What is the best way to have a website accessible to iPhones?
clickable column
Change additional 32-bit printer drivers - SBS 2008
To clear or not to clear ARP cache